aa = ''
out_str = '%6.0f' % aa
print out_str
Is there a way to print an empty string with the formatting shown above? The reason why I need this is because the variable aa can sometimes store an actual float and other times it will be empty. But i do need to output it in the specified format. float(aa) does not work on an empty string.
EDIT:
How about the following?
aa = ''
ab = 23
out_str = '%6.0f%6.0f' % (aa,ab)
print out_str
EDIT:
In above example,
aa = '', ab=23 would have to print six spaces, followed by 23 with four leading spaces
aaorabto be valid and the other to be invalid, printing only the valid one?aa = '',ab=23would have to print six spaces, followed by23with four leading spaces?