|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
def power(x,y):
if y == 1:
return x
else:
return x * power(x,y-1)
zhi,mi = map(int((input('请输入指数和幂:').split())))
result = power(zhi,mi)
print('%d的%d次幂为:%d' %(zhi,mi,result))
实际运行的话会报以下错误:
int() argument must be a string, a bytes-like object or a number, not 'list'
百度查了下加了map函数,但是还是会报返回错误,如果要改的话需要改哪里呢?想请问以下大家,谢谢
map里你少打个逗号
- def power(x,y):
- if y == 1:
- return x
- else:
- return x * power(x,y-1)
- zhi,mi = map(int,(input('请输入指数和幂:').split()))
- result = power(zhi,mi)
- print('%d的%d次幂为:%d' %(zhi,mi,result))
复制代码
|
|