【发布时间】:2020-09-04 11:45:50
【问题描述】:
我正在创建一个程序,我在其中接受用户的输入,即他们的名字、姓氏和年龄。我必须计算10年后的年龄。 我制作的程序是:
name=input("Enter your first name: ")
name1=input("Enter your last name: ")
age=int(input("Enter your age: "))
counter=age+10
print(name + name1 + ", you will be" + counter + " years old in 2030")
首先它显示以下错误:
print(name + name1 + ", tou will be" + counter + "years old in 2030")
TypeError: can only concatenate str (not "int") to str
比它不打印 10 年后的年龄。 请帮帮我!
【问题讨论】:
-
你应该在
name1和name2之间加一个空格,在, tou will be之后加一个空格(以及修正拼写)
标签: python