[Tutor] Newbie
"Simón A. Ruiz"
sruiz at canterburyschool.org
Wed Jul 23 20:14:41 CEST 2008
Sam Last Name wrote:
> Hey guys, I'm wanting to learn Python and eventually how to program with
> it. I'm 16 and very eager to learn. I already have a question.
>
> Heres my script:
> print "Hello World!"
> print "Here are the ten numbers from 0 to 9"
> for i in range(10) :
> print i,
> print "Goodbye World!"
>
> Result of my script :
> Hello World!
> Here are the ten numbers from 0 to 9
> 0 Goodbye World!
> 1 Goodbye World!
> 2 Goodbye World!
> 3 Goodbye World!
> 4 Goodbye World!
> 5 Goodbye World!
> 6 Goodbye World!
> 7 Goodbye World!
> 8 Goodbye World!
> 9 Goodbye World!
>
>
> I don't Understand. I have an idea it something like Goodbye world is
> threading together with the numbers? Feedback is Thanked :)
It would help if you explain what it was you *expected* as an output.
Otherwise we have to guess. :-)
If what you expected was something like:
Hello World!
Here are ten numbers from 0 to 9
0 1 2 3 4 5 6 7 8 9 Goodbye World!
Then you want that final print statement to not be included in your for
loop block; i.e., unindent it:
for i in range(10):
print i,
print "Goodbye World!"
Hope this helps!
Simón
More information about the Tutor
mailing list