Gary Wessle wrote:
I am going through this tut from
http://ibiblio.org/obp/thinkCS/pytho...ish/chap07.htm
I am getting errors running those 2 groups as below as is from the tut
Next time, please copy and paste the complete "traceback", the error
messages that clutter your screen when something goes wrong.
index = 0
while index < len(fruit):
letter = fruit[index]
print letter
index = index + 1
for char in fruit:
print char
Does the error message you get look like this?
Traceback (most recent call last):
File "<stdin>", line 1, in ?
NameError: name 'fruit' is not defined
That is because you are using a variable named fruit before you have
assigned a value to it. Put
fruit = "Banana"
before your snippet and everything should work as expected.
Peter