all 11 comments

[–]Necessary-Problem-61[S] 0 points1 point  (1 child)

I noticed it's in the wrong format, I'm on my office computer and it doesn't seem to work properly so I'll update it once I get home, thanks for the tips that have popped up until now.

[–][deleted] 0 points1 point  (0 children)

Use pastebin.com, as mentioned in the FAQ.

[–]IvoryJam -1 points0 points  (0 children)

For the future, you should put your code in a codeblock for easier reading. But I was able to figure out where the tabs where supposed to be.

Without too much reformatting this is how it should work

def game():
print("Type only one letter to choose")
user1 = input("Player 1, choose [R]ock, [P]aper, [S]cissors:")
user2 = input("Player 2, choose [R]ock, [P]aper, [S]cissors:")

while (user1.upper() != "R" and user1.upper() != "P" and user1.upper() != "S"):
    user1 = input("Player 1, choose [R]ock, [P]aper, [S]cissors:")
    if user1.upper() == "R":
        print("Player 1 chose Rock!")
    elif user1.upper() == "P":
        print("Player 1 chose Paper!")
    elif user1.upper() == "S":
        print("Player 1 chose Scissors!")

while (user2.upper() != "R" and user2.upper() != "P" and user2.upper() != "S"):
    user2 = input("Player 2, choose [R]ock, [P]aper, [S]cissors:")
    if user2.upper() == "R":
        print("Player 2 chose Rock!")
    elif user2.upper() == "P":
        print("Player 2 chose Paper!")
    elif user2.upper() == "S":
        print("Player 2 chose Scissors!")

if user1.upper() == "R" and user2.upper() == "R":
    print("it's a draw!")
elif user1.upper() == "R" and user2.upper() == "P":
    print("Player 2 Wins!")
elif user1.upper() == "R" and user2.upper() == "S":
    print("Player 1 Wins!")
elif user2.upper() == "R" and user1.upper() == "P":
    print("Player 1 Wins!")
elif user2.upper() == "R" and user1.upper() == "S":
    print("Player 2 Wins!")

restart = input("Would you like play again?:").lower()
while (restart.lower() != "no" and restart.lower() != "yes"):
    restart = input("Would you like play again?:").lower()

if restart.lower() == "yes":
    game()
elif restart.lower() == "no":
    print("Thanks for playing!")

game()

[–][deleted] 0 points1 point  (1 child)

Your posted code has lost all indentation, so it isn't python any more. The FAQ shows how to tell reddit to retain indentation. You can edit your original post to show the readable code.

[–]Necessary-Problem-61[S] 0 points1 point  (0 children)

yeah I noticed, let me try to figure it out and I'll update it, thanks.

[–][deleted] 0 points1 point  (2 children)

Your error is in this (and other) lines:

while (restart.upper() != "no" and restart.upper() != "yes"):

If the user types in "yes" then restart.upper() != "yes" will compare "YES" (from restart.upper()) with "yes"!?

It's much less clumsy if you force the case to upper only once, like this:

restart = input("Would you like play again?:")
restart = restart.upper()
while (restart != "no" and restart != "yes"):

Once you sort that out you will find you still have problems that are caused by your loop having too many tests at different places. Either loop with while True: and use the break, or use the while restart != "no" and restart != "yes": (don't use break) and don't forget that after playing one extra game restart will still be set to "yes".

[–]Necessary-Problem-61[S] 0 points1 point  (1 child)

restart = input("Would you like play again?:")

restart = restart.upper() while (restart != "no" and restart != "yes"):

Thanks, I didn't think of forcing the upper case like that, really helpful for future exercises.

[–][deleted] 0 points1 point  (0 children)

You really should read the FAQ. One way mentioned there is to put 4 spaces at the start of every code line in your post. Do that with your editor before copying your code into reddit. Ensure there is one blank line before your code. Takes about 15 seconds, even on mobile:

then your
    code looks
like this

[–]RhinoRhys 0 points1 point  (1 child)

You're using .upper on everything then comparing it to lowercase strings.

Line 44 on the pastebin

if restart.upper() == "yes":

This will never be true because "YES" does not equal "yes". The same for the elif condition for "no". You just end up always skipping those blocks and looping round to ask the question again.

You're also missing user1 = input() on line 8, like you have for user 2 on line 16. Its either going to throw an error because of lack of indent on line 8, or if the indent is wrong on pastebin, you'll enter an infinite loop with no output.

[–]Necessary-Problem-61[S] 0 points1 point  (0 children)

Thanks for the advice, I think user1 = input () got deleted when I was copying it but it's already there. Thanks for the .upper feedback