Help With Python
Thomas Guettler
guettli at thomas-guettler.de
Wed Jan 26 11:15:48 EST 2005
Am Wed, 26 Jan 2005 15:55:28 +0000 schrieb Judi Keplar:
>
> I am currently taking a course to learn Python and was looking for
> some help. I need to write a Python statement to print a comma-
> separated repetition of the word, "Spam", written 511 times ("Spam,
> Spam,
Spam").
>
> Can anybody help me get started? I am completely new to programming!
Hi,
# This way, there is a comma after the last:
import sys
for i in range(511):
sys.stdout.write("Spam, ")
# No comma at the end:
mylist=[]
for i in range(511):
mylist.append("Spam")
print ", ".join(mylist)
Thomas
--
Thomas Güttler, http://www.thomas-guettler.de/
More information about the Python-list
mailing list