forked from EnigmaVSSUT/Induction-2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpython task done
40 lines (34 loc) · 1.19 KB
/
python task done
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import random
while True:
player1 = input("first player name ==> ")
player2 = input("second player name ==> ")
target = int(input(" please Enter the target number: "))
score1 = 0
score2 = 0
while True:
if (score1 < target) and (score2 < target):
input(f"{player1} press Enter to roll the dice.")
dice1 = int(random.randint(1, 6))
print(f"Dice rolled {dice1}")
score1 = score1+dice1
input(f"{player2} press enter to roll the dice.")
dice2 = int(random.randint(1, 6))
print(f"Dice rolled {dice2}")
score2 = score2+dice2
print(f"{player1}'s Score: {score1}\n{player2}'s Score: {score2}")
if score1 > target:
score1 = score1-dice1
if score2 > target:
score2 = score2-dice2
if score2 == target:
print(f"{player2} you are the winner!!")
break
if score1 == target:
print(f"{player1} you are the winner!!")
break
replay = input("press y to keep playing or any other thing to exit : ")
if replay.lower() == "y":
continue
else:
print("GAME END")
break