Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Head First Python problem
-
I just started learning Python with Pythonista and the book 'Head First Python'
There is an exercise which I do not understand. I create a list variable: eg
movies = [ 'and', 'bin', 'can','den']
and then the code snippet:
for each_item in movies: print(each_item)
and
bin
can
denWhich as expected prints each string on a new line. When I put this code into this function:
def print_list(My_list):
for an_item in My_list:
if isinstance(My_list,list):
print_list(an_item)
else:
print(an_item)
print_list(movies)the list entries print out each character of each string on a new line. What is going on here?
a
n
d
b
i
n
.
.
. -
I think you want if isinstance(an_item, list):
-
I think You want if isinstance(an_item, list):
-
Thanks,
that works.