如何在python上添加 [英] How to add on python

查看:75
本文介绍了如何在python上添加的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个程序,可以询问某人的年龄-然后告诉他们,下个生日他们将是 x 岁。



例如:



python =你几岁了?

回答= 17



python =在您的下一个生日,您将18岁。



这是我要制作的程序,但是我在如何将 1 添加到年龄这一问题上陷入了困境的人

解决方案

如何?

 年龄+ = 1 

 年龄=年龄+ 1 

请确保您正在将用户的输入从字符串转换为整数。 p>

I am trying to make a program where I can ask someone's age - then tell them that on their next birthday they will be x many years old.

for example:

python = "How old are you?"
answer = "17"

python = "On your next birthday you will be 18 years old".

that is the program which I am trying to make however I am stuck on how to add 1 to the age of the person

解决方案

How about this?

age += 1

or

age = age + 1

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

这篇关于如何在python上添加的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆