Created
May 6, 2020 12:14
-
-
Save DaChelimo/e167f4f4441c28d49db8c010c0a96c58 to your computer and use it in GitHub Desktop.
Implementing my knowledge for the random module in this simple project.
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 random | |
count = 0 | |
def roller(): | |
global count | |
count += 1 | |
num_choice = range(1, 7) | |
num = num_choice[random.randint(1, 6)] | |
print("The dice landed on " + "{}\n".format(num)) | |
choice = input("Do you want to roll again(y/n): ") | |
choice = choice.strip() | |
if choice == "y" and count < 20: | |
roller() | |
else: | |
pass | |
roller() | |
""" | |
import random | |
count = 0 | |
def roller(): | |
global count | |
count += 1 | |
num_choice = range(1, 7) | |
num = num_choice[random.randint(1, 6)] | |
print("The dice landed on " + "{}\n".format(num)) | |
def attempts(rolller): | |
choice = input("Do you want to roll again(y/n): ") | |
if choice == "y": | |
roller() | |
attempts(roller) | |
else: | |
pass | |
attempts(roller()) | |
""" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment