سلام
بعد از یک دست بازی کردن بازی به اتمام می رسه و حلقه break میشه
دستواتی رو هم که بعد از if یا elif نوشتم اجرا نمی شن
import random
print(" let's play : \"rock , paper , scissors\"")
randomNumber = random.randint(0,2)
player2 = 'rock'
if randomNumber == 0 :
player2 = 'rock'
elif randomNumber == 1 :
player2 = 'paper'
elif randomNumber == 2 :
player2 = 'scissors'
player1_wins = 0
player2_wins = 0
player1 = 'rock'
while player1_wins < 4 and player2_wins < 4 :
player1 = input( 'player1 make your move:').lower()
print( f'player2 make your move: {player2}')
if player1 == 'q' or 'quit' :
break
if ( player1 == 'rock' and player2 == 'scissors' ) or ( player1 == 'paper' and player2 == 'rock' ) or ( player1 == 'scissors' and player2 == 'paper' ):
print( 'player1 wins!...')
player1_wins += 1
elif ( player2 == 'rock' and player1 == 'scissors' ) or ( player2 == 'paper' and player1 == 'rock' ) or ( player2 == 'scissors' and player1 == 'paper' ):
print( 'player2 wins!...' )
player2_wins += 1
elif ( player1 == player2 ):
print( 'that`s a tie ...')
player1_wins += 0
player2_wins += 0
else:
print( 'there is a wrong')
print( f' Fainal rusalt is player1 : {player1_wins} and player2 : {player2_wins}')
اینطوری اجرا میشه
let's play : "rock , paper , scissors"
player1 make your move:rock
player2 make your move: paper
Fainal ruslat is player1 : 0 and player2 : 0
سلام !
مشکل شما در این خطه
if player1 == 'q' or 'quit' :
break
جمله شرطیتون اشتباهه
باید این طوری بنویسی
if player1 == 'q' or player1 == 'quit':
break