0
How to run this code correctly.
6 Respuestas
+ 1
or better style maybe would be:
print ("hello\n welcome to my code!...")
age=input()
print ("you are of="+age+"years")
age=int(age)
x= 2017-age
print (x)
(I'm sorry, I'm not this good in Python 🙈)
+ 1
print ("hello\n welcome to my code!\nplease enter your age")
age=int(input())
agestr=str(age)
print ("you are of="+agestr+"years")
x = 2017-age
print (x)
+ 1
it's a useless extra variable, as you can see in my second answer, it's omittable.
Anyways, Python auto-converts to the mostfitting data types automatically most of the time, but it seems to be hard to change back from string and also to string, if you hard cast it to be integer. that's why i used the extra variable. But if you cast after printing the String (or adding up to a return string), you don't need the other variable.
+ 1
thanks
0
thanks jakobi
0
what is that agestr in your code