+ 1
How to fix this code?
I just starded with python and i get the error "nonetype" how to fix? This is my code age = input("What is your age in years? ") print("if your birthday was today you would be") print(age)+print("Years old") agem = int(age) * 12 print(agem)+print("Months old") aged = int(age) * 365.25 print(aged)+ print("Days old")
4 Respuestas
+ 8
Robin Hamerslag ,
You can't concatenate two print statements...
You can concatenate only the values within one print statement...
here look at this:-
https://code.sololearn.com/cn1C4lyQsiKL/?ref=app
this is without concatenation....just use comma....
https://code.sololearn.com/cZzz2l82A5NJ/?ref=app
+ 5
Robin Hamerslag ,
if you convert the input of age to int just during input, you can avoid all further convertions. follow the second sample of Riya and modify the code like this scheme: var = int(input(...))
0
age = input("What is your age in years? ")
print("If your birthday was today, you would be")
print(age, "Years old") # Fixed the print statements
agem = int(age) * 12
print(agem, "Months old") # Fixed the print statements
aged = int(age) * 365.25
print(aged, "Days old") # Fixed the print statements
0
You can use the f string for example: print(f'age: {age} years old
')