How to add on python [closed]

你。 提交于 2019-12-02 15:06:34

How about this?

age += 1

or

age = age + 1

Make sure you are casting the user's input from a string to an integer.

In order to increase age by one, you need it to be an integer. Try:

age = int(input("How old are you? ")
age += 1
print("On your next birthday you will be" + str(age) + "years old")
age = input('How old are you?')
print('On your next birthday you will be' + str(int(age)+1) + 'years old.')
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!