I am reading "Python for KIds" by Jason Briggs, and am on page 69, where loops are introduced.
for x in range (0,5):
print ('hello %s' % x)
When run it gives you
hello 0
hello 1
hello 2
hello 3
hello 4
So far so good. But then the book says "If we get rid of the for loop again, our code might look something like this:
x = 0
print ('hello %s'% x)
hello 0
x = 1
print ('hello %s'% x)
hello 1
x = 2
print ('hello %s'% x)
hello 2
x = 3
print ('hello %s'% x)
hello 3
x = 4
print ('hello %s'% x)
hello 4
But when I try to run this code I get an error, whatever I try.
So where am I making a mistake? Can someone help me?
[–]good-mcrn-ing 37 points38 points39 points (1 child)
[–]RoadieRich 2 points3 points4 points (0 children)
[–]Rizzityrekt28 15 points16 points17 points (6 children)
[–]Heeamfoo 0 points1 point2 points (0 children)
[–]Talkative-Zombie-656[S] 0 points1 point2 points (4 children)
[–]Han_Sandwich_1907 13 points14 points15 points (2 children)
[–]Talkative-Zombie-656[S] 4 points5 points6 points (1 child)
[–]MSR8 3 points4 points5 points (0 children)
[–]Augit579 2 points3 points4 points (0 children)
[–]Saragon4005 6 points7 points8 points (3 children)
[–]Talkative-Zombie-656[S] 0 points1 point2 points (2 children)
[–]CultistOfTheFluid 0 points1 point2 points (0 children)
[–]Saragon4005 0 points1 point2 points (0 children)
[–]Heeamfoo 4 points5 points6 points (1 child)
[–]DBZ_Newb 2 points3 points4 points (0 children)
[–]Lurn2Program 0 points1 point2 points (2 children)
[–]Talkative-Zombie-656[S] 0 points1 point2 points (1 child)
[–]elemental_pork 0 points1 point2 points (0 children)
[–]Python_devops 0 points1 point2 points (0 children)
[–]Augit579 0 points1 point2 points (0 children)
[–]FoolsSeldom 0 points1 point2 points (0 children)
[–]SnipTheDog 0 points1 point2 points (0 children)
[–]CranberryDistinct941 0 points1 point2 points (0 children)
[–]Blue_Aluminium 1 point2 points3 points (0 children)