Python newbie problems -


i finished watching video https://www.youtube.com/watch?v=qo4zn5uzsvg, , though teaches 2.0 edition python, notes pop 3.0 uses of python. nevertheless, in end, challenges provided, 1 of them this:

def returntwo():     return 20,30 x,y = returntwo() print(x,y) 

whenever try see conclusion be, comes

def returntwo():     return 20,30 (red x in 3.5 shell) x,y = returntwo() syntaxerror: invalid syntax. 

what can do?

the python shell allows interactively run commands. useful when doing quick calculations of check small pieces of code.

in case, want define function. defining function that: a definition. later on, call function , make run. issue here function (often) defined in more 1 line. means, hit enter before finish define function. reason, tell shell finished enter:

enter image description here

this applies if define function in single line:

enter image description here

and that's reason why syntaxerror: line x, y = returntwo() supposed in function, that, need indented (to level of return 20, 30):

enter image description here

like @jim said, try pressing enter until >>> prompt again!


remember three little dots have meaning too.


this question answered in comments @helios35 , @jim!

i elaborate , post answer here future users.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -