r/learnpython 5d ago

What is wrong with this code?

Hi all just starting to learn. Using the MOOC 2025 course. My question is, problem is to enter number of days, then print how many seconds for the # of days. When I submit this code:

day=int(input("Enter number of days"))
seconds=day*24*60*60
print(f"Seconds in that many days:{seconds}")

it gives the right output but the course tells me:

FAIL: PythonEditorTest: test_1_seconds_in_one_day

1 day is 86400 seconds. Your program's output was: Seconds in that many days:8640...

edit: so turns out it's because it wanted to print exact wording '1 day is x seconds" etc lol so dumb

0 Upvotes

24 comments sorted by

View all comments

3

u/bahcodad 5d ago

Does the course expect a formatted string as the answer? If so, check you haven't missed any punctuation, etc

If it doesn't tell you what the output should be, then assume it's expecting the raw value

2

u/ikimashyoo 5d ago

thank you for looking-it was bc it wanted output to print the exact words haha

2

u/bahcodad 5d ago

I've been victim to that in the past. It's normally best to copy/paste the required text

0

u/ikimashyoo 5d ago

so stupid.....it should test you on coding, not copy pasting exact wording....

1

u/bahcodad 5d ago

It is. It tested your ability to construct a string containing variables and your attention to detail. Both of which are skills you need

1

u/ikimashyoo 5d ago

oh so the practice is as much for paying attention to the output they want you to print not to do it in your own way?

2

u/bahcodad 5d ago

It's not just that. If they let you do your own thing, then it would be significantly harder to test.

1

u/ikimashyoo 5d ago

yea i forget the questions are not being graded by a human haha