+ 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")

30th Aug 2023, 6:05 AM
Robin Hamerslag
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
30th Aug 2023, 6:14 AM
Riya
Riya - avatar
+ 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(...))
30th Aug 2023, 10:54 AM
Lothar
Lothar - avatar
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
31st Aug 2023, 12:07 PM
S2XPHOENIX🇮🇳
S2XPHOENIX🇮🇳 - avatar
0
You can use the f string for example: print(f'age: {age} years old ')
1st Sep 2023, 3:23 AM
funzd _
funzd _ - avatar