while userInput in op and userInput != "q":
score += 1
no_words += 1
userInput = input((str(no_words)) + ". ").lower()
while userInput not in op and userInput != "q":
score += 0
no_words += 0
print("Oops! Invalid input")
userInput = input((str(no_words)) + ". ").lower()
I expect when the user gives an input, my program will read through both these while loops each time in order to provide a correct output. ( I'm building a game which the users will need to list out as many words they can base on the origin word.)
for example: Extreme
Goal of the game: The more words user able to give, the higher the score will be.
What you want to do is actually nest the condition within the loop.
Also, you'll never need to hardcode in "+ 0" to anything. if it doesn't change, you can simply leave out the line.
userInput = None
while userInput != 'q':
userInput = input((str(no_words)) + ". ").lower()
if userInput in op:
score += 1
no_words += 1
else:
print('Oops! Invalid Input')
Edit: The important takeaway is that you can't run through two different while loops at the same time; the first one ends by the time the second one starts, until you get to some more advanced techniques. The solution is to figure out how to use a single while loop to access all the different paths of what could be happening at that moment.