print("Let's play another game:\n\nRock, Paper & Scissors")
print("""Instead of Rock we choose: r
Instead of Paper we choose: p
Instead of Scissors we choose: s\n""")
user1 = input("user1 -> ")
user2 = input("user2 -> ")
print()
if user1=="r":
if user2=="r":
print("ting tong! match draw")
elif user2=="p":
print("user1","\033[031m""looses""\033[0m","user2","\033[032m""win""\033[0m","by covering the rock with paper")
elif user2=="s":
print("user2","\033[031m""looses""\033[0m","user1","\033[032m""win""\033[0m","by smashing the scissors with rock")
else:
print("\033[030m""Invalid Move""\033[0m")
elif user1=="p":
if user2=="r":
print("user2","\033[031m""looses""\033[0m","user1","\033[032m""win""\033[0m","by covering the rock with paper")
elif user2=="p":
print("Ka Chaow, Match Draw")
elif user2=="s":
print("user1","\033[031m""looses""\033[0m","user2","\033[032m""win""\033[0m","by cutting the paper with scissors")
else:
print("\033[030m""Invalid Move""\033[0m")
elif user1=="s":
if user2=="r":
print("user1","\033[031m""looses""\033[0m","user2","\033[032m""win""\033[0m","by smashing the scissors with rock")
elif user2=="p":
print("user2","\033[031m""looses""\033[0m","user1","\033[032m""win""\033[0m","by cutting the paper with scissors")
elif user2=="s":
print("Slash match draw")
else:
print("\033[030m""Invalid Move""\033[0m")
CodePudding user response:
If you want to play indefinitely you can put all this code in while(true):
If you want the first player to reach X points to win and end the game you can do this before your code :
points=[0,0]
while not(X in points):
your code...
`and whenever a player wins, increase his points total by 1 like this:
points[0] =1
(this makes player 1 have 1 more point)
CodePudding user response:
To repeat the game many times, you can easily wrap the whole code inside a while statement and also add an exit key like
char = ''
while True:
# Put your code here
char = input('Do you want to continue y/n')
if ( char == 'n' ) :
break
So if the user input a character n
then the program will exit, else it will create a new game!