Last active
January 7, 2023 10:24
-
-
Save ozcanyarimdunya/93f4d854103d1531c9aa951cd3a92958 to your computer and use it in GitHub Desktop.
itertools cycle example
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import itertools | |
import time | |
cycle = itertools.cycle(['-', '/', '|', '\\']) | |
for i in range(5): | |
print("Loading", next(cycle), end="\r") | |
time.sleep(.5) | |
print("Finished!") | |
cycle = itertools.cycle(['.', '..', '...', '....']) | |
for i in range(5): | |
print("Waiting", next(cycle), f"{'':<5}", end="\r") | |
time.sleep(.5) | |
print("Finished!") |
Author
ozcanyarimdunya
commented
Jan 7, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment