0
What's wrong with this function? What does it mean "outside function"? P.s. I'm literally new to this.
Original Code: 23 # Return the list of generated suits 24 return generated_suits Output File "file0.py", line 24 return generated suits ^ SyntaxError: 'return' outside function
1 Resposta
+ 3
A function is a block of code that has a name, possibly some arguments, and a result which is called the return value.
In Python, the function definition begins with the "def" keyword, and the function body is indented (usually the line starts with 4 whitespaces).
A return statement is only meaningful inside a function block. You get syntax error if you write return in the global scope, because there is nowhere to return to.
I recommend you start with the Python course on Sololearn, all is explained step by step.
https://www.sololearn.com/Course/Python-for-Beginners/?ref=app