问题
if cake == "delicious":
return "yes"
SyntaxError: 'return' outside function
Why I get like this?
回答1:
You can create some functions like this.
text ="delicious"
def check(text):
if text=="delicious":
return 'yes'
check(text)
回答2:
return
is a keyword which can only appear in a function definition (as the syntax error says). You can simply print your output in an if/else block
if cake == 'delicious': print('yes')
来源:https://stackoverflow.com/questions/52773539/why-am-i-getting-this-error-in-python-when-i-enter-into-next-line-of-if-else-con