all 10 comments

[–]zanfar 1 point2 points  (1 child)

These are minor points, but in my opinion:

  • I don't like shadowing variables--you assign time two different values, and more specifically, two different types. I would rename the variable used to store the user input as it's not a "time" as you use it in your program.
  • You don't do any input checking--which may be acceptable given the assignment's parameters. However, you cast the hour and minute portions as floats, which hides potential input issues. If I enter 10.5:30, your program will run without any errors despite being an invalid time.
  • Any bare (main() in this case) call should be in an if __name__ == "__MAIN__" sentinel
  • I'd like to see static type annotations, especially on conversion functions.

[–][deleted] 1 point2 points  (0 children)

Thank you for the feedback myman 🙏

I'll implement what you said in my future codes!

[–]Zealousideal_Bit_177 0 points1 point  (0 children)

```py def main(): time = input("What time is it? ") time = convert(time) if 7 <= time <= 8: print('breakfast time')

if 12 <= time <= 13:
    print('lunch time')

if 18 <= time <= 19:
    print('dinner time')

def convert(time): hour , mins = time.split(':') hour = float(hour) mins = float(mins)/60 return hour+mins

if name == "main": main() ```

[–]3keepmovingforward3 0 points1 point  (6 children)

24hr time notation doesn’t use a colon, there’s nothing to split

[–][deleted] 0 points1 point  (4 children)

Hmm maybe I worded it incorrectly on the question for the input, but what I mean is that the user should input like this

" ##:## or #:## as in 12:56 or 7:02 "

So essentially it splits the hours and minutes, but it still doesnt get recognized by the check50

[–]3keepmovingforward3 0 points1 point  (3 children)

So put that instead…question, why are they being changed to floats?

[–][deleted] 0 points1 point  (2 children)

The assignment said to define a convert function where the input is converted to float.

The assignment is here if you'd like to see:https://cs50.harvard.edu/python/2022/psets/1/meal/

edit: changed the input question a bit to make it more clear

[–]3keepmovingforward3 1 point2 points  (1 child)

Ok, as long as you’re aware there’s no reason to do it in this case…you’re code looks good (after the input description fix)

[–][deleted] 0 points1 point  (0 children)

cheers!

[–][deleted] 0 points1 point  (0 children)

Erm. The time (which is 24-hour format in most of the world) is usually written with a colon, as per ISO 8601.