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)
6 odpowiedzi
+ 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: "))
+ 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
+ 2
n will contain the input string, 60*60*24*365 = 31,536,000 times 👌
+ 2
thanks all
+ 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")
0
so in python allways need to declare number = int letters = string?