0

No output in phyton

Here is simple code but don’t get it why I don’t get anything for output blank screen?? Thanks sec=60 min=60 hour=24 day=356 year=input("Enter how many years you want to calculate? ") n=sec*min*hour*day*year print(n)

6th Mar 2019, 5:18 PM
Marius
6 Antworten
+ 7
It may be 'cuz input always returns a string and not a number. You need to convert it to int explicitly. You can do it like year= int(input("Year: "))
6th Mar 2019, 5:22 PM
Шащи Ранжан
Шащи Ранжан - avatar
+ 3
Every input is in string format, you first have to convert it to a real number. Simple pattern: year = int(input) In real life, where people might input nonsense, you can for example write: while True: year = input() if year.isdigit(): year = int(year) break
6th Mar 2019, 5:23 PM
HonFu
HonFu - avatar
+ 2
n will contain the input string, 60*60*24*365 = 31,536,000 times 👌
6th Mar 2019, 5:46 PM
Anna
Anna - avatar
+ 2
thanks all
6th Mar 2019, 6:10 PM
Marius
+ 2
thank you again all works good sec=60 min=60 hour=24 day=356 year=float(input("Enter how many years you want to calculate? ")) n=sec*min*hour*day*year print(n, "seconds in ", year, "years") print("THANKS ALL")
6th Mar 2019, 6:19 PM
Marius
0
so in python allways need to declare number = int letters = string?
6th Mar 2019, 6:11 PM
Marius