it's not breaking and I don't know why This is the problem section of the code. It is working fine, the try except is fine, and the check if not in range's break is working fine. But not the second one.
It checks if the input's in range, it's in range, it prints the input. It doesn't break. It continues instead. It then miraculously works the second time you input within the range.
import random
random.seed(10)
def userInput():
while True:
try:
userInput=int(input('Type 1 for rock, 2 for scissors, or 3 for paper: '))
while userInput not in range(1,4,1):
print('Invalid input')
break
except:
print('Invalid input')
continue
if userInput in range(1,4,1):
print(userInput)
break
if userInput==1:
return 'rock'
if userInput==2:
return 'scissors'
if userInput==3:
return 'paper'
def convertChoiceToString(compChoice):
if compChoice==1:
return 'I choose rock'
elif compChoice==2:
return 'I choose scissors'
elif compChoice==3:
return 'I choose paper'
#def rockPaperScissors():
def main():
print('Rock Paper Scissors')
userInput()
print('You chose',userInput())
compChoice=random.randrange(1,3,1)
print(convertChoiceToString(compChoice))
main()