Dice "Game"
So, just started python a weeks time ago, so I'm looking for feedback/critique on things i can do to improve my code. I wrote a little user/pc dice rolling game. Any feedback at all is appreciated!
def dice(n: int) -> tuple:
"""
Simple function to roll 'n' number of dices.
Returns numbers of each roll and a total.
:param n: number of dices to roll
:return: dices_numbers, total
"""
numbers = []
total = 0
for dices in range(n):
number = random.randint(1, 6)
numbers.append(number)
total += number
dices_numbers = ", ".join(map(str, numbers))
return dices_numbers, total
def dice_check(user_total: int = 0, pc_total: int = 0) -> None:
"""
Function to check whether user or pc won dice roll.
:param user_total: user's total roll
:param pc_total: pc's total roll
:return: None
"""
if user_total > pc_total:
print("Congratulations! You won")
elif user_total < pc_total:
print("Sorry, BOT wins!")
else:
print("Tie!")
number_of_dices = ""
user_roll = ""
pc_roll = ""
while True:
number_of_dices = int(input("How many dices would you like to roll?"
" (0 to quit) >"))
if number_of_dices == 0:
break
else:
user_roll = dice(number_of_dices)
pc_roll = dice(number_of_dices)
print(f"You: Roll: {user_roll[0]}, a total of: {user_roll[1]}")
print(f"BOT: Roll: {pc_roll[0]}, a total of: {pc_roll[1]}")
dice_check(user_roll[1], pc_roll[1])