-
Notifications
You must be signed in to change notification settings - Fork 2.2k
day 3 challenge #782
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
day 3 challenge #782
Conversation
bbelderbos
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool!
|
|
||
| def main(): | ||
| pomodoro_count = 0 | ||
| while True: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there anything that would break out of this loop?
| from datetime import timedelta | ||
|
|
||
| def timer(timer_type): | ||
| if timer_type == "pomodoro": |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the only difference here are the number of minutes, so you could turn this into a dictionary: timer_times = {'pomodoro': 25, 'short_break': 5, 'long_break': 10}, then you don't have to repeat endtime = datetime.now() + timedelta(minutes=<int>) 3 times
|
|
||
| while (datetime.now().replace(microsecond=0) != endtime.replace(microsecond=0)): | ||
| timeleft = endtime - datetime.now() | ||
| timeleft = str(timeleft).split(".")[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or:
>>> timeleft
datetime.timedelta(seconds=9, microseconds=687388)
>>> timeleft.seconds
9
| while (datetime.now().replace(microsecond=0) != endtime.replace(microsecond=0)): | ||
| timeleft = endtime - datetime.now() | ||
| timeleft = str(timeleft).split(".")[0] | ||
| print(f"{timeleft}", end='\r') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is \r something you had to do for Windows?
| @@ -0,0 +1,46 @@ | |||
| import time | |||
| from datetime import datetime | |||
| from datetime import timedelta | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do in one import: from datetime import datetime, timedelta
ATTENTION: before clicking "Create Pull Request" please submit some meta data, thanks!
Difficulty level (1-10): 4
Estimated time spent (hours): <1
Completed (yes/no): yes
I stretched my coding skills (if yes what did you learn?): more practice with lists and datetime
Other feedback (what can we improve?): []