Hello!
I have the following code:
>>> x = 0
>>> y = 3
>>> while x < y:
... print '{0} / {1}, '.format(x+1, y)
... x += 1
Output:
1 / 3,
2 / 3,
3 / 3,
I want my output like:
1 / 3, 2 / 3, 3 / 3
I searched and found that the way to do this in a single line would be:
sys.stdout.write('{0} / {1}, '.format(x+1, y))
Is there another way of doing it? I don't exactly feel comfortable with sys.stdout.write()
since I have no idea how it is different from print
.