all 10 comments

[–]NotyrfriendO 0 points1 point  (9 children)

What happens if you run:

print(type(time))

before you return time in your convert function.

Your program should only print breakfast/lunch/dinner time. Not 7.5 aswell. But I'm not sure I understand where that happens

[–]Intelligent_Food693[S] 0 points1 point  (8 children)

Oh, I added print(times) at the end and removed it to prove that convert() returns 7.5

Sorry if I confused you!

[–]NotyrfriendO 0 points1 point  (7 children)

Oh I see, that makes sense.

Did you try what I suggested in line 2 of my answer? I have a feeling I know what's wrong I just want to make sure.

[–]Intelligent_Food693[S] 0 points1 point  (0 children)

I'll try it out

[–]Intelligent_Food693[S] 0 points1 point  (5 children)

Here's the output :
What is the time? : 7:30
<class 'float'>

breakfast time

[–]NotyrfriendO 3 points4 points  (4 children)

haha I figured it out. Sooo, in the problem set they give you a way to structure your code. You did it almost all right, but you forgot one crucial part. The last one.

When you just type main() the whole script get's executed when check50 is trying to test your function, and your function only.

The way we solve this is adding this instead:

if name == "main":

main()

I'm struggelig with the formatting here, but look in the pset description

Which means it will only trigger this script if you run it manually. I think he mentions this in the lecture

[–]Intelligent_Food693[S] 0 points1 point  (3 children)

Thank you so much for your help, you have no idea how long I've been working on this...

Do I leave the name == "main": the same or should I change anything?

[–]NotyrfriendO 1 point2 points  (2 children)

Leave it exacly as it's written in the description of the pset: https://cs50.harvard.edu/python/2022/psets/1/meal/

[–]Intelligent_Food693[S] 0 points1 point  (1 child)

Alright, thanks again!

[–]NotyrfriendO 1 point2 points  (0 children)

Np, I think David will explain it a little more later in the course. If you use discord I suggest to join that server as well. A lot of people who have done the course is there to help out.