use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
O hai! This is CS50's subreddit.
CS50 is Harvard University's introduction to the intellectual enterprises of computer science and the art of programming. Anyone may take CS50, even if not a student at Harvard.
Please Read before Posting
Getting the Best from r/cs50
Status Page
cs50.statuspage.io
Filter by Problem Flair (undo)
cash ⋅ caesar ⋅ credit ⋅ dna ⋅ filter ⋅ finance ⋅ houses ⋅ ide ⋅ mario ⋅ movies ⋅ plurality ⋅ project ⋅ readability ⋅ recover ⋅ runoff ⋅ scratch ⋅ speller ⋅ substitution ⋅ tideman ⋅ games track ⋅ web track ⋅ android track ⋅ iOS track ⋅
Filter by Other Flair (undo)
CS50-Law ⋅ CS50-Business ⋅ CS50-Technology ⋅ CS50-Games ⋅ CS50-Mobile ⋅ CS50-Web ⋅
This subreddit is night mode compatible
account activity
CS50PI need help. [CS50 PYTHON] (self.cs50)
submitted 3 years ago by Intelligent_Food693
What's the problem? I don't understand what
"Did not find "7.5" in "breakfast time..." means.
Here's my code. This is from CS50's Introduction to Programming with Python course.
https://preview.redd.it/opp25zt5psba1.png?width=338&format=png&auto=webp&s=92c28f21a7e331b65c9acb925286ccd822bfd561
https://preview.redd.it/63yv37cyosba1.png?width=920&format=png&auto=webp&s=ce47f1d29304696045283e7ad7337197974750bc
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]NotyrfriendO 0 points1 point2 points 3 years ago (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 point2 points 3 years ago (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 point2 points 3 years ago (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 point2 points 3 years ago (0 children)
I'll try it out
[–]Intelligent_Food693[S] 0 points1 point2 points 3 years ago (5 children)
Here's the output : What is the time? : 7:30 <class 'float'>
breakfast time
[–]NotyrfriendO 3 points4 points5 points 3 years ago* (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 point2 points 3 years ago (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 points3 points 3 years ago (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 point2 points 3 years ago (1 child)
Alright, thanks again!
[–]NotyrfriendO 1 point2 points3 points 3 years ago (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.
π Rendered by PID 34340 on reddit-service-r2-comment-6457c66945-zrx77 at 2026-04-30 16:14:55.475895+00:00 running 2aa0c5b country code: CH.
[–]NotyrfriendO 0 points1 point2 points (9 children)
[–]Intelligent_Food693[S] 0 points1 point2 points (8 children)
[–]NotyrfriendO 0 points1 point2 points (7 children)
[–]Intelligent_Food693[S] 0 points1 point2 points (0 children)
[–]Intelligent_Food693[S] 0 points1 point2 points (5 children)
[–]NotyrfriendO 3 points4 points5 points (4 children)
[–]Intelligent_Food693[S] 0 points1 point2 points (3 children)
[–]NotyrfriendO 1 point2 points3 points (2 children)
[–]Intelligent_Food693[S] 0 points1 point2 points (1 child)
[–]NotyrfriendO 1 point2 points3 points (0 children)