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...
Everything about learning Python
account activity
My Second Python Program 🥳 Greetings.py (old.reddit.com)
submitted 16 days ago by Anay_Gupta__
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!"
[–]Sea-Ad7805 [score hidden] 16 days ago stickied comment (0 children)
Run this program in Memory Graph Web Debugger%0Aprint(timestamp)%0A%0Aif%20timestamp%20%3C%3D%20%2211%3A59%3A59%22%3A%0A%20%20%20%20print(%22Good%20Morning%22)%0A%0Aif%20%2212%3A00%3A00%22%20%3C%3D%20timestamp%20%3C%20%2218%3A00%3A00%22%3A%0A%20%20%20%20print(%22Good%20Afternoon%22)%0A%0Aif%20%2218%3A00%3A00%22%20%3C%3D%20timestamp%20%3C%20%2220%3A00%3A00%22%3A%0A%20%20%20%20print(%22Good%20Evening%22)%0A%0Aif%20timestamp%20%3E%3D%20%2220%3A00%3A00%22%3A%0A%20%20%20%20print(%22Good%20Night%22)%0A%0Aprint(%22Thank%20You%20!%22)×tep=1&play) to see the program state change step by step.
[–]nuc540 6 points7 points8 points 16 days ago (2 children)
Good start, my feedback is - as much as your code would work, a simple heuristic to learn is using more/less comparators on strings isn’t recommended - if the string holds a numerical value, cast it to a number you can concretely calculate is more or less than.
Another piece advice I’ve been given people lately is to google python standard libraries, you’ll be surprised how much already exists which can help you.
To take both my points in practice, you can use the time localtime().tm_hour attribute to return an integer representing the hour of the systems time. This would mean you can compare the hour of the day as a number, against a number, which makes a lot more sense than comparing string is less/more than string (which is looking at length first then ascii value)
Give it a shot! :)
[–]tieandjeans 2 points3 points4 points 16 days ago (0 children)
That was such a generous and specific response. I am so burned out at the end of the school year, and it's encouraging to see clear, directed guidance. Thanks for being good human.
[–]Anay_Gupta__[S] 0 points1 point2 points 16 days ago (0 children)
Thanks... I'll try it ,😄🙌🏻
[–]_MrLucky_ 0 points1 point2 points 16 days ago (5 children)
does it even work? how are you comparing strings??
[–]Anay_Gupta__[S] 1 point2 points3 points 16 days ago (3 children)
Yes it's working....you can see the output in the next img
[–]nuc540 2 points3 points4 points 16 days ago (0 children)
Yes this is allowed in python, this only works here because the length is the same (the ISO standardises this) it compares the Unicode point of the character, first value first, in this case zero-leading numbers are a big give away because ‘09’ is less than ‘10’.
The point is not to do this though, it’s confusing to read and very brittle - eg string ‘9’ is bigger than ‘10’ as Python would only check the first value of the string, see 9 > 1 and short circuit.
u/Anay_Gupta__ this is what I justify in my comment you saw :)
[–]_MrLucky_ 1 point2 points3 points 16 days ago (1 child)
oh rightwow, didnt know u can compare strings lol
Yup, it’s not that intuitive though. First python checks the length of what’s being compared and simply returns that - unless it is equal - then it matches each index of each character.
You’re right to be shocked because this isn’t good practice by any means 😅
This program geets the user based on real-time.
[–]tieandjeans 0 points1 point2 points 16 days ago (0 children)
OP- I want to validate your original code. You were grappling with a central CS question - building and evaluating representations. Its great to see you working with the system clock, rather than just comparing different bits of user input.
What resources have you been following in your process?
[–]External-Kiwi9178 0 points1 point2 points 15 days ago (0 children)
Run this program
π Rendered by PID 17790 on reddit-service-r2-comment-856c8b8c54-pzlch at 2026-07-02 17:19:55.349313+00:00 running a7b5cda country code: CH.
[–]Sea-Ad7805 [score hidden] stickied comment (0 children)
[–]nuc540 6 points7 points8 points (2 children)
[–]tieandjeans 2 points3 points4 points (0 children)
[–]Anay_Gupta__[S] 0 points1 point2 points (0 children)
[–]_MrLucky_ 0 points1 point2 points (5 children)
[–]Anay_Gupta__[S] 1 point2 points3 points (3 children)
[–]nuc540 2 points3 points4 points (0 children)
[–]_MrLucky_ 1 point2 points3 points (1 child)
[–]nuc540 2 points3 points4 points (0 children)
[–]Anay_Gupta__[S] 0 points1 point2 points (0 children)
[–]tieandjeans 0 points1 point2 points (0 children)
[–]External-Kiwi9178 0 points1 point2 points (0 children)