Why am I getting this error in python when i enter into next line of if-else condition?

前端 未结 2 1000
無奈伤痛
無奈伤痛 2021-01-29 09:34
if cake == \"delicious\":
    return \"yes\"

SyntaxError: \'return\' outside function

Why I get like this?

2条回答
  •  迷失自我
    2021-01-29 10:17

    You can create some functions like this.

    text  ="delicious" 
    def check(text):
        if text=="delicious":
            return 'yes'
    
    check(text)
    

提交回复
热议问题