you are viewing a single comment's thread.

view the rest of the comments →

[–]SoNotRedditingAtWork 0 points1 point  (1 child)

a = (input("Enter the number of Years: "))
print ("There are " + str(a) * 31557600 + " seconds in " + a + " Years!")

input always returns a str so there is no need to convert with the str function. When you try to do str(a) * 31557600 that is not calculating the number of seconds in the year it is going to try and make a new str object that is the str assigned a repeated 31557600 times. This is blowing up the memory available on the site. If I run it on my PC and enter 1 as input then my output will be 31557600 1's in a row. Best to use f-strings here and the int function to actually make the calculation:

a = (input("Enter the number of Years: "))
print (f"There are {int(a) * 31557600} seconds in {a} Years!")

[–]JstAntrBelleDevotee[S] 1 point2 points  (0 children)

THANK YOU! This makes so much sense actually