Skip to content
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

Duration Dictionary Idea #17

Open
Alphabetsoup16 opened this issue Feb 26, 2023 · 0 comments
Open

Duration Dictionary Idea #17

Alphabetsoup16 opened this issue Feb 26, 2023 · 0 comments

Comments

@Alphabetsoup16
Copy link

jaccuse/main.py

Line 196 in 7e10ab5

if duration == "sec":

Instead of this block:

if duration == "sec":
    update_display(counter, duration)
    sleep(1)
    counter += 1
elif duration == "min":
    update_display(counter, duration)
    sleep(60)
    counter += 1
elif duration == "hour":
    update_display(counter, duration)
    sleep(3600)
    counter += 1
elif duration == "day":
    update_display(counter, duration)
    sleep(86400)
    counter += 1
else:
    print("error")
    break

You can have a dictionary like:
duration_dict = {"sec":1, "minute":60, "hour":3600, "day":86400}
And then replace the block with:

if duration:
    update_display(counter, duration)
    sleep(duration_dict[duration])
    counter += 1
else:
    print("error")
    break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant