Python 我的代码有一个错误,我就是想不出来
代码: 错误消息:Python 我的代码有一个错误,我就是想不出来,python,linux,Python,Linux,代码: 错误消息: current = input (" Now subtract it by 1. Uh-Oh, My calculator is broken, please tell me what the difference is.") current = int(current) print (" OK, my calulator is up and running. We must multiply the number with 13. Its alright, I have
current = input (" Now subtract it by 1. Uh-Oh, My calculator is broken, please tell me what the difference is.")
current = int(current)
print (" OK, my calulator is up and running. We must multiply the number with 13. Its alright, I have the answer here.")
print (current*13 + " is the product")
回溯(最近一次呼叫最后一次):
文件“/home/pi/Desktop/birth trick.py”,第13行,在
打印(当前*13+“为产品”)
TypeError:不支持+:“int”和“str”的操作数类型
请告诉我如何改进代码。错误
不支持+:“int”和“str”的操作数类型。
表示Python无法将字符串添加到整数中。在这种情况下,current
是一个整数,“是产品”
是字符串
要解决此问题,您可以执行以下操作:
Traceback (most recent call last):
File "/home/pi/Desktop/birthday trick.py", line 13, in <module>
print (current*13 + " is the product")
TypeError: unsupported operand type(s) for +: 'int' and 'str'
print("%d is the product" % current * 13)