为什么此函数返回LinkedIn而不是Amazon?
def hey(location):
location = "LinkedIn"
answer = "Welcome to " + location
return answer
print(hey("Amazon"))
答案 0 :(得分:0)
因为您在函数内部将location
声明为"LinkedIn"
。
如果没有为"LinkedIn"
输入任何参数,如果您希望location
为默认值,请尝试:
def hey(location="LinkedIn"):
return "Welcome to " + location