+ 1

A syntax error

Hello! I'm learning some basics of coding in my free time, chose Python as my first language (except some HTML in middle school). I was trying out some things from the python 3 tutorial in IDLE and discovered a syntax error I just finished the generators lesson and I wrote this (it's the same as in the lesson): def make_word(): word = "" for ch in "spam": word +=ch yield word print(list(make_word())) and the thing is, it's working on the code playground, but giving me a syntaxerror (higlighting "print") in the python shell. Why is that?

2nd May 2017, 11:12 AM
Paweł Szczepański
Paweł Szczepański - avatar
1 Antwort
+ 1
oh, I think I got it! I just had to press enter again after defining the function, and THEN print the result. :P I was just trying to do it all at once.
2nd May 2017, 11:18 AM
Paweł Szczepański
Paweł Szczepański - avatar