0
print("hello") x=input(" what is your name ") y=(len(x)) z=input(" what is your age ") s=str(y+z) print(s)
this program give me error.. I don't find problem.. any Methmetics is not happening in this program..
3 Answers
+ 5
by default input() return a string
so z is already of string type
two solution to your problem
#first:
z = int ( input(" what is your age"))
s = str(y+ z)
''' this will add length to the age and then convert it to the string, addition of numbers'''
#second:
s = str(y) + z
''' in this z will remain in string type, we just have to convert y, this will result in length of name followed by the age, append two string'''
Edit:
as your question doesn't clarify what do you want to do? gave you both the solution, choose according to your need.
+ 2
Please post a topic like "Help with code please" and then put all the details within the question.
0
Z=input('What is your age'). Now this is a string.
you need to convert the string into integer for math as Y is an integer.
print('Hello')
X=input('What is your name')
Y=(len(X))
Z=input('What is your age')
A=int(Z)
S=str(Y+A)
print(S)
now this will do the math you asked for!