I am trying to write an application to convert bytes to kb to mb to gb to tb. Here\'s what I have so far:
def size_format(b): if b < 1000: r
When you divide the value you're using an integer divide, since both values are integers. You need to convert one of them to float first:
return '%.1f' % float(b)/1000 + 'KB'
or even just
return '%.1f' % b/1000.0 + 'KB'