Stone, Paper and Scissors game: Tips: 1."import random" from library file. 2.Use nested if and else 3.You should know stone, paper and scissor game. Code: import random print("Hello!!\nPlay Rock! Paper! Scissor!\nUser v/s Computer.") print('Who ever wins 5 times first becomes the winner of the game.') player_count=0 comp_count=0 while(True): if player_count>=5 or comp_count>=5: break; x=random.choice(['rock','paper','scissor']) print("\nComp = "+str(comp_count)+" | You = "+str(player_count)+"\nEnter your choice:",end=' ') n=input() if(n!=x): print("\ncomputer choose:",x) print("you choose:",n,"\n") if(x=='rock' and n=='paper'): print("you win!") player_count=player_count+1 elif(x=='paper' and n=='scissor')
Thank you sir
ReplyDelete