Aug-26-2020, 07:40 AM
Hello All,I am working on some python projects and i want to confirm that the given sample code is correct or not? Basica;;y the objective is a random function: to generate rock, paper, or scissors. valid function: to check the validity of the move. result function: to declare the winner of the round. scorekeeper: to keep track of the score. Or can anyone suggest me some new python projects as a beginner level?
""" Rock Paper Scissors ---------------------------------------- """ import random import os import re os.system('cls' if os.name=='nt' else 'clear') while (1 < 2): print "\n" print "Rock, Paper, Scissors - Shoot!" userChoice = raw_input("Choose your weapon [R]ock], [P]aper, or [S]cissors: ") if not re.match("[SsRrPp]", userChoice): print "Please choose a letter:" print "[R]ock, [S]cissors or [P]aper." continue // Echo the user's choice print "You chose: " + userChoice choices = ['R', 'P', 'S'] opponenetChoice = random.choice(choices) print "I chose: " + opponenetChoice if opponenetChoice == str.upper(userChoice): print "Tie! " #if opponenetChoice == str("R") and str.upper(userChoice) == "P" elif opponenetChoice == 'R' and userChoice.upper() == 'S': print "Scissors beats rock, I win! " continue elif opponenetChoice == 'S' and userChoice.upper() == 'P': print "Scissors beats paper! I win! " continue elif opponenetChoice == 'P' and userChoice.upper() == 'R': print "Paper beat rock, I win! " continue else: print "You win!"