0

what is uncorrect here?

import random while True: pturn = input("rock,paper or scisors? ") fturn = random.randint(1, 3) if fturn == 1 and pturn == "papper" or fturn == 2 and pturn == "scisors" or fturn == 3 and pturn == "rock": win = True elif fturn == 1 and pturn == "rock" or fturn == 3 and pturn == "scisors" or fturn == 2 and pturn == "paper": win = False elif fturn == 1 and pturn == "scisors" or fturn == 2 and pturn == "rock" or fturn == 3 and pturn == "paper": win = False

5th Jan 2023, 5:39 PM
Petru SĂźnchetru
Petru SĂźnchetru - avatar
3 Answers
+ 2
Hello, I think you forgot the brackets for the conditions. If I'm interpreting your code correctly, you should be bracketing the "and" conditions. So for example: if (fturn == 1 and pturn == "papper") or (fturn == 2 and pturn == "scisors") or (fturn == 3 and pturn == "rock"): win = True Otherwise, the conditions are understood differently. I hope I have been able to help you, if not, you will have to specify the problem.
5th Jan 2023, 6:05 PM
Flinn
+ 1
This code can't work in sololearn because sololearn send code to its server and show us final output, but your code keep asking for new input (on sololearn we need to place all inputs at once) I tested this code in online editor, and it have few bugs: 1. You never print anything to console, you forgot to place for example print(win) 2. In first if statement you typed "papper" but in others are "paper", you also tell in Input to type paper - simple typo 3. scisors is typed with 2 s, so scissors, english is probably not your native language, and it is fine, you can also use translator or auto correct, code does not brake because it 4. MAIN BUG: your inputs does not work correctly it will check for example: True and False => FALSE then FALSE and FALSE it continue chain https://learnpython.com/blog/multiple-conditions/ Please use tags to tag language for example, for this code it is clear that it is in python. https://code.sololearn.com/W3uiji9X28C1/?ref=app https://code.sololearn.com/WhiNb9BkJUVC/?ref=app
5th Jan 2023, 6:09 PM
PanicS
PanicS - avatar
+ 1
Also check this to learn how to use correctly multiple logic operators in one if statement, on other languages we use () to separate, but it look like python miss this feature https://kodify.net/python/if-else/if-conditions/ https://www.dataquest.io/blog/tutorial-using-if-statements-in-python/ You may also see how others are solved this problem, it is common, so you can find on internet
5th Jan 2023, 6:29 PM
PanicS
PanicS - avatar