Created
November 4, 2022 12:46
-
-
Save greg76/4fd71941124ee03d3a90fa5313c70d6d to your computer and use it in GitHub Desktop.
emojie animals racing in the terminal
This file contains 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 os | |
import time | |
import random | |
animals = "๐ ๐๐ฆ๐ฆฃ๐๐ฆ๐ฆ๐ช๐ฆ๐ฆ๐ฆฌ๐๐๐๐๐๐๐ฆ๐๐ฆ๐๐๐๐๐ฆ" | |
#animals = "๐ถ๐ฑ๐ญ๐ฐ๐ฆ๐ป๐ผ๐ฆ๐ฏ๐จ๐ป๐ฎ" | |
width = os.get_terminal_size().columns - 2 | |
pos = [width] * len(animals) | |
def main(): | |
while min(pos) > 0: | |
os.system('clear') | |
for i, a in enumerate(animals): | |
pos[i] -= random.choice([0,1]) | |
print(" " * pos[i], a) | |
time.sleep(.05) | |
winner = "".join([animals[i] for i, x in enumerate(pos) if x == min(pos)]) | |
print("The Winner is:", winner, "๐๐") | |
if __name__ == '__main__': | |
main()% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment