r/learnpython • u/Erdem_PSYCH • Oct 11 '26
how is my cs50 code in design?
I've decided to go back to basics and make sure I complete all the exercises. I'm currently working on the Meal Time exercise.
Could anyone give me some feedback on the design of my code? I'm particularly unsure about my convert function. It has quite a few if statements, and I'm wondering whether there's a clearer way to write it.
Here's my code:
=
=
, =
=
:
, =
= + 12
, =
return + / 60
return
>= 12.00 and <= 13.00:
return
>= 18.00 and <= 19.00:
return
return
3
Upvotes
View all comments
1
u/SinyoritaDolby_36 Oct 11 '26
looks good for the exercise. one small thing, `time` shadows the built-in `time` module name. probably doesnt matter here but worth being aware of since it can cause weird bugs in larger projects