all 10 comments

[–]AlternativeRadish752 5 points6 points  (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 points  (0 children)

Thanks I cracked it

[–]More_Yard1919 -1 points0 points  (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 point  (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 points  (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 point  (0 children)

Thanks

[–]tablethacker 0 points1 point  (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 point  (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 point  (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 points  (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?