Files
python_101/dice.py
2025-10-13 10:47:09 +02:00

54 lines
1.2 KiB
Python

import random
player1 = ["" , 0 ]
player2 = ["" , 0 ]
player1[0] = input("what's your name ? : ")
print(f"welcome, {player1[0]}")
player2[0] = input("what's your name ? : ")
print(f"welcome, {player2[0]}")
winScore = 3
def isWinning( score , wscore ):
if score[1] >= wscore:
print(f"THE BIG WINNER IS {score[0]}")
while True:
user1Val = input(f"{player1[0]} give a numbers 1 - 6 : ")
user1Val = int(user1Val) # convert to int
user2Val = input(f"{player2[0]} give a numbers 1 - 6 : ")
user2Val = int(user2Val) # convert to int
result = random.randint(1,6) # draw a number
if user1Val == result and user2Val == result:
print("YOU BOTH WIN")
player1[1] = player1[1] + 1
player2[1] = player2[1] + 1
elif user1Val == result: # test result
print("USER 1 YOU WIN")
player1[1] = player1[1] + 1
elif user2Val == result:
print("USER 2 YOU WIN")
player2[1] = player2[1] + 1
else:
print("YOU ALL LOOOOOOSE")
print("the good value was :" + str(result))
isWinning(player1,winScore)
isWinning(player2,winScore)
print(f"the scores is : {player1[0]} : {player1[1]} / {player2[0]} : {player2[1]}")