|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
def shui(x,y,z):
chars=[0,1,2,3,4,5,6,7,8,9]
for x in chars:
for y in chars:
for z in chars:
if x*100+y*10+z==x**3+y**3+z**3:
a=x*100+y*10+z
print(a,end='')
shui(x,y,z)
错误类型:
Traceback (most recent call last):
File "C:/Users/lenovo/AppData/Local/Programs/Python/Python36-32/水仙花.py", line 12, in <module>
shui(x,y,z)
NameError: name 'x' is not defined
因为你在定义函数def shui(x,y,z):的时候规定了要传入参数(x,y,z),所以你在调用函数shui()的时候需要传入三个参数如:shui(1,2,3)。但是根据你的思路,你在定义函数的时候应该不要传入参数直接这样写def shui():就好了。
|
|