more code to dice
This commit is contained in:
29
dice.py
29
dice.py
@@ -1,7 +1,14 @@
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
score1 = ["jane" , 0 ]
|
player1 = ["" , 0 ]
|
||||||
score2 = ["jhon" , 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
|
winScore = 3
|
||||||
|
|
||||||
@@ -12,35 +19,35 @@ def isWinning( score , wscore ):
|
|||||||
|
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
user1Val = input("numbers 1 - 6 : ")
|
user1Val = input(f"{player1[0]} give a numbers 1 - 6 : ")
|
||||||
user1Val = int(user1Val) # convert to int
|
user1Val = int(user1Val) # convert to int
|
||||||
user2Val = input("numbers 1 - 6 : ")
|
user2Val = input(f"{player2[0]} give a numbers 1 - 6 : ")
|
||||||
user2Val = int(user2Val) # convert to int
|
user2Val = int(user2Val) # convert to int
|
||||||
|
|
||||||
result = random.randint(1,6) # draw a number
|
result = random.randint(1,6) # draw a number
|
||||||
|
|
||||||
if user1Val == result and user2Val == result:
|
if user1Val == result and user2Val == result:
|
||||||
print("YOU BOTH WIN")
|
print("YOU BOTH WIN")
|
||||||
score1[1] = score1[1] + 1
|
player1[1] = player1[1] + 1
|
||||||
score2[1] = score2[1] + 1
|
player2[1] = player2[1] + 1
|
||||||
|
|
||||||
|
|
||||||
elif user1Val == result: # test result
|
elif user1Val == result: # test result
|
||||||
print("USER 1 YOU WIN")
|
print("USER 1 YOU WIN")
|
||||||
score1[1] = score1[1] + 1
|
player1[1] = player1[1] + 1
|
||||||
|
|
||||||
elif user2Val == result:
|
elif user2Val == result:
|
||||||
print("USER 2 YOU WIN")
|
print("USER 2 YOU WIN")
|
||||||
score2[1] = score2[1] + 1
|
player2[1] = player2[1] + 1
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("YOU ALL LOOOOOOSE")
|
print("YOU ALL LOOOOOOSE")
|
||||||
print("the good value was :" + str(result))
|
print("the good value was :" + str(result))
|
||||||
|
|
||||||
isWinning(score1,winScore)
|
isWinning(player1,winScore)
|
||||||
isWinning(score2,winScore)
|
isWinning(player2,winScore)
|
||||||
|
|
||||||
print(f"the scores is : {score1[0]} : {score1[1]} / {score2[0]} : {score2[1]}")
|
print(f"the scores is : {player1[0]} : {player1[1]} / {player2[0]} : {player2[1]}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user