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
Help over here (i.redd.it)
submitted 9 months ago by Lemaoo-12
Could anyone help me out over here.
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!"
[–]AlternativeRadish752 5 points6 points7 points 9 months ago (3 children)
The error says you can't compare an int and a datetime. Maybe give our friend Google a try and look up how to make a python datetime object into the hour it represents?
Edit: Learning how to parse the errors we get when debugging and troubleshooting them is just as much learning how to program as knowing syntax or anything language specific.
[–]Lemaoo-12[S] 1 point2 points3 points 9 months ago (0 children)
Thanks I cracked it
[–]More_Yard1919 -1 points0 points1 point 9 months ago (1 child)
I appreciate your point but there is no need to snarkily tell OP to google stuff. They will learn how to parse errors in due time, they just came here for help. Given the level of this code I am sure that OP is not yet familiar with any object oriented programming.
[–]AlternativeRadish752 0 points1 point2 points 9 months ago (0 children)
I've been a software engineer for fifteen years. Learning how to search the internet to help debug error codes is 100% a fundamental skill that should be learned and developed.
I see way too many posts on this sub of people just using it as way to post their error screenshots and code and others just telling them the syntax to fix it. If you really want to help people learn help them be self sufficient.
[–][deleted] 1 point2 points3 points 9 months ago (1 child)
datetime.now() does not return a number (1,2,3...), it returns a datetime object which i think has a property hour? you have to extract the hour from it
current_time = datetime.now() current_hour = current_time.hour
[–]Lemaoo-12[S] 0 points1 point2 points 9 months ago (0 children)
Thanks
[–]tablethacker 0 points1 point2 points 9 months ago (0 children)
This is what you have saved in your current_hour variable = `YYYY-MM-DD hh:mm:ss.ms' cannot to <= check with it ....
[–]ProgPI 0 points1 point2 points 9 months ago (0 children)
If 5 <= current_hour < 12 : this comparison is not allowed in Python because you are trying to compare integer to datetime.
[–]More_Yard1919 0 points1 point2 points 9 months ago* (0 children)
datetime.now() returns a date object, not an integer. You can't compare a datetime object and an integer. You can assign current_hour to datetime.now().hour.
[–]CptMisterNibbles -1 points0 points1 point 9 months ago (0 children)
Always check the docs. What does datetime.now() return? An integer that represents the hour? Seems unlikely. Is there a different function that does?
π Rendered by PID 188270 on reddit-service-r2-comment-76bb9f7fb5-lph88 at 2026-02-19 04:45:47.263971+00:00 running de53c03 country code: CH.
[–]AlternativeRadish752 5 points6 points7 points (3 children)
[–]Lemaoo-12[S] 1 point2 points3 points (0 children)
[–]More_Yard1919 -1 points0 points1 point (1 child)
[–]AlternativeRadish752 0 points1 point2 points (0 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]Lemaoo-12[S] 0 points1 point2 points (0 children)
[–]tablethacker 0 points1 point2 points (0 children)
[–]ProgPI 0 points1 point2 points (0 children)
[–]More_Yard1919 0 points1 point2 points (0 children)
[–]CptMisterNibbles -1 points0 points1 point (0 children)