py3: a
['Mary', 'had', 'a', 'little', 'lamb', 'break']
py3: for w in a:
...     print(w)
... print('Huh?')
  File "<stdin>", line 3
    print('Huh?')
        ^
SyntaxError: invalid syntax

I don't understand why this throws a SyntaxError.  If I wrap
essentially the same code into a function it works:

py3: def print_list(a_list):
...     for item in a_list:
...             print(item)
...     print('Huh?')
...
py3: print_list(a)
Mary
had
a
little
lamb
break

What am I not understanding here?

-- 
boB
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to