Newbie requesting help

Hey All, complete noob at this. Here is my question:

# This is my first python project
calc_to_secs = 24 * 60 * 60
num_of_days = input('Enter the number of days: ')
print(f'20 days are {calc_to_secs * num_of_days} seconds')

This gives result:

Enter the number of days: 2
20 days are 222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222222 seconds

Process finished with exit code 0

What am I doing wrong?

thanks for help!

i tried this also:

# This is my first python project
calc_to_secs = 24 * 60 * 60
num_of_days = input('Enter the number of days: ')
print(num_of_days)
print(calc_to_secs)
calc_answer = num_of_days * calc_to_secs
print(calc_answer)

ok NM :slight_smile:
I fixed it,

# This is my first python project
calc_to_secs = 24 * 60 * 60
num_of_days = input('Enter the number of days: ')
print(num_of_days)
print(calc_to_secs)
calc_answer = int(num_of_days) * 24 * 60 * 60
print(calc_answer)

Glad you were able to fix it! Just for any other learners that may have this issue in future, the reason for the problem is that input() takes in the input as a string type, no matter what you want it to be. As such it was doing "2" * 86400 which just creates a string that’s 86,400 characters long, with each character being a 2. That’s why OP’s solution now works, as you convert it to an int first and thus the calculation is possible.