I coded Rock, Paper, Scissors. I added the randomness, made it loop at the 
user's request, added win code, no problems there. I changed some strings to 
F-strings to practice using them, and now the first "elif" in my if loop 
(player chooses rock, bot chooses paper) doesn't work. Any help ideas? I 
checked syntax, no error messages other than mine that I added
Pasting code below the line:
_____________________________________________________________________________
import random #Allows for a random input.
options = ["Rock", "Paper", "Scissors"] #Tells the computer what its options 
are.
playerchoices  = []
repeat = True
while repeat == True:
  rand_choice = random.randint(1,3)
  choice = options[rand_choice-1] #defines player options and selection
  while True:
    player_choice = input("Welcome to Rock, Paper, Scissors. To begin, choose 
Rock, Paper, or Scissors. ")
    if player_choice == "Rock":
      break
    if player_choice == "Paper":
      break
    if player_choice == "Scissors":
      break 
    else:
      print("Invalid input, try again. Capitalize your response and ensure 
proper spelling. ") #Lines 10-19 give the player a choice as to what to pick.
#The code below determines victory status.
  if player_choice == "Rock" and choice == options[0]:
    print(f"Computer played {options[0]}. Tie.")
    playerchoices.append("Rock")
  elif player_choice == "Rock " and choice == "Paper":
    print(f"Computer played  {options[1]}. You lose.")
    playerchoices.append("Rock")
  elif player_choice == "Rock" and choice == options[2]:
    print(f"Computer played  {options[2]}. You win.")
    playerchoices.append("Rock")
  elif player_choice == "Paper" and choice == options[0]:
    print(f"Computer played {options[0]}. You win.")
    playerchoices.append("Paper")
  elif player_choice == "Paper" and choice == options[1]:
    print(f"Computer played {options[1]}. Tie.")
    playerchoices.append("Paper")
  elif player_choice == "Paper" and choice == options[2]:
    print(f"Computer played {options[2]} . You lose.")
    playerchoices.append("Paper")
  elif player_choice == "Scissors" and choice == options[0]:
    print(f"Computer played {options[0]}. You lose.")
    playerchoices.append("Scissors")
  elif player_choice == "Scissors" and choice == options[1]:
    print(f"Computer played  {options[1]}. You win.")
    playerchoices.append("Scissors")
  elif player_choice == "Scissors" and choice == options[2]:
    print(f"Computer played  {options[2]}. Tie.")
    playerchoices.append("Scissors")
  else:
    print("If you're reading this, I messed up somehow")
    print(f"Choice: {choice}")
    print(f"You played: {player_choice}")
  playagain = True
  while playagain == True:
    ask_repeat = input("Play again? Y/N ")
    if ask_repeat == "Y":
      print("Restarting... ")
      repeat = True
      playagain = False
    elif ask_repeat == "N":
      repeat = False
      playagain = False
      print("Goodbye.")
    else:
      playagain = True
      repeat = False
      print("Error. Input either Y or N. Capitalize and retry.")
-- 
https://mail.python.org/mailman3//lists/python-list.python.org

Reply via email to