My script.
Wojtek Walczak
gminick at hacker.pl
Sun Dec 8 04:05:36 EST 2002
Dnia Sun, 08 Dec 2002 08:53:58 +0000, John Ochiltree napisaĆ(a):
>> for i in range(b):
>> print i + ". I am a bad computer :("
>> But that gives me an error. What's the correct way to concatenate
>> variables?
> Commas - print i, ". I am a bad computer :("
It works, but outputs looks not especially nice because there's a space
between a digit and a dot.
0 . I am a bad computer :(
1 . I am a bad computer :(
2 . I am a bad computer :(
3 . I am a bad computer :(
...
What he really need to do is to convert digit to string:
for i in range(b):
print str(i) + ". I am a bad computer :("
or use formats:
for i in range(b):
print "%d. I am a bad computer :(" % (i)
HTH.
--
[ ] gminick (at) underground.org.pl http://gminick.linuxsecurity.pl/ [ ]
[ "Po prostu lubie poranna samotnosc, bo wtedy kawa smakuje najlepiej." ]
More information about the Python-list
mailing list