Skip to content

Instantly share code, notes, and snippets.

@DaChelimo
Created May 6, 2020 12:14
Show Gist options
  • Save DaChelimo/e167f4f4441c28d49db8c010c0a96c58 to your computer and use it in GitHub Desktop.
Save DaChelimo/e167f4f4441c28d49db8c010c0a96c58 to your computer and use it in GitHub Desktop.
Implementing my knowledge for the random module in this simple project.
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