- 1
Q. Anna is 18 years old
Can anybody tell me the code. It shows error in code
8 Réponses
+ 5
#Don't put anything as argument to input function. compare your output with expected
name = input()
age = int( input() )
print( name + " is "+ str( age ) + " years old")
+ 3
Code is.
name = input("Anna")
age = input("18")
print(name + " is " + age + " years old")
+ 2
Share your code here by saving it playground..
That helps to find mistakes..
+ 1
Bro, if I tell you simplest method then it would be really funny.
And it is,
print("Anna is 18 years old")
You can apply another method. However, it is little bit advanced for beginners.
name = input("Enter the name: ")
age = int(input(" Enter the age:"))
print(name+"is"+age+"years old")
0
Second line of your code write like this
age = input()
Don't pass anything
0
Name = Anna
Age = 18
print(Name,"is",Age,"years old")
0
name = input()
age = input()
print(name + " is " + age + " years old")
- 1
I would have used a formatted string literal as last line like this:
print(f"{name} is {age} years old")