在使用return返回结果值时,报错:SyntaxError: invalid syntax

大家好,我在学习python的max()的时候,书上作者说max()其实就是类似于索引出结果,于是他给出了一个例子,我在尝试时报错了,但我没看明白错误在哪,代码内容具体如下:

img

tuple1=(1,2,3,4,5,6)
temp=tuple1[4]
for each in tuple1:
if each>temp:
temp=each
return temp

这段代码在运行的时候,报错将r标红并出现错误原因:SyntaxError: invalid syntax

我搜索了该错误的出现情况但我没能看明白,请问这种该怎么解决?
另,tuple1是我自己写的我觉得应该不影响中间循环代码的运行吧

删除return,改成用print输出

tuple1=(1,2,3,4,5,6)
for each in tuple1:
    if each>temp:
        temp=each
print(temp)

报错指向哪个变量啊?
python讲究层级,你这代码贴出来也没有层级,怎么判断啊

你没有定义函数,不可以return啊

是不是你对其方式有问题啊

在写print(temp)之前,按两次回车就好了