“原因”;返回函数之外的值”;Python中的语法错误?
我的代码有问题“原因”;返回函数之外的值”;Python中的语法错误?,python,syntax-error,Python,Syntax Error,我的代码有问题 'return' outside function (<module1>, line 4) <module1> 4 有任何解决方案吗?在此函数中,返回值未正确缩进 def break_words(stuff): """This function will break up words for us.""" words = stuff.split(' ') return words 缩进已关闭,请尝试以下操作: def b
'return' outside function (<module1>, line 4) <module1> 4
有任何解决方案吗?在此函数中,
返回值未正确缩进
def break_words(stuff):
"""This function will break up words for us."""
words = stuff.split(' ')
return words
缩进已关闭,请尝试以下操作:
def break_words(stuff):
"""This function will break up words for us."""
words = stuff.split(' ')
return words
缩进是Python的关键组件,与其他一些语言不同,因此确保代码的格式正确非常重要。缩进在Python中很重要。从您粘贴的内容来看,这里的最后两行不属于break_单词的范围
def break_words(stuff):
"""This function will break up words for us."""
words = stuff.split(' ')
return words
@用户1653037不客气,感谢我们接受您喜欢的任何答案。看见
def break_words(stuff):
"""This function will break up words for us."""
words = stuff.split(' ')
return words