For those who use Python 2.6. In 2.6, the following code will result in an error.
for i in range(10):
if(i%2 == 0):
print("{} is even".format(i))
else:
print("{} is odd".format(i))
print("done")
2.6 doesn't seem to work with the above writing style. http://stackoverflow.com/questions/10054122/valueerror-zero-length-field-name-in-format-python
for i in range(10):
if(i%2 == 0):
print("{0} is even\n".format(i))
else:
print("{0} is odd\n".format(i))
print("done")
If so, it works.
We recommend using 2.7 or 3 series.
Recommended Posts