[Tutor] Newbie Anxiety
Alan Gauld
alan.gauld at freenet.co.uk
Fri Nov 11 00:16:22 CET 2005
> In Basic, I would have said:
>
> 10 x = x + 1 : print x : goto 10
Tsk, tsk, even in BASIC that's considered bad form :-)
10 FOR X =1 to 10
20 PRINT X
30 NEXT
Would be the better BASIC form.
And as you've seen Python provides a close analog to
that in its for loop.
for X in [1,2,3,4,5,6,7,8,9,10]:
print X
OR
for X in range(1,11):
print X
> goes toward visualizing how things are
> going flow and be constructed without line numbers and the venerable
> GOTO statement.
I discuss why this is a bad idea in the old version of my tutor, which
compared Python to old style BASIC. You might find it helpful if you
were weaned on BASIC. You can still find the old site here:
http://www.freenetpages.co.uk/hp/alan.gauld/oldtutor/
Check out the Loops topic for the GOTO discussion.
Alan G
Author of the learn to program web tutor
http://www.freenetpages.co.uk/hp/alan.gauld
More information about the Tutor
mailing list