jeudi 19 décembre 2019

Create a race in Python?

I'm very new to python 3. As an assignment, I am supposed to make a race in python basic Syntax and without importing any other additional function, where 3 mice are racing with different odds of winning.

from random import randint
import time


def race():
    z = '----{,_,">'  # The mouse.
    j = ' '
    print('\t'*13, '|')  # The finish line. Very sophisticated.
    while len(z) < 50:
        time.sleep(1)
        #or k in range(3):
        x = randint(1, 6)
        j = ' ' * x
        z = j + z
        print("\r" + str(z), end="")  # For clearing printed text. I prefer not to import os.

As you might see, I've managed to make one; Two to go. But I've scratching my head for three hours on how to do it, that is how to make them go simultaneously ... Any help will be appreciated.




Aucun commentaire:

Enregistrer un commentaire