0

I'm asking input from the user and wanted to check if he used the right letters to continue, I've wrote this code, but even when I write "y" or "n", it doesn't exit the loop, and I have no idea why:

while True:
    start = input("Want to start? (Y/n) ").lower()
    if start != 'y' or 'n':
        print("letter not accepted! Please write 'Y' to start or 'N' to exit!\n")
    else:
        break

if start == "y":
    separate(players)
else:
    print("Goodbye!")
4
  • Check if this helps :stackoverflow.com/questions/14594522/… Commented Jul 30, 2017 at 18:52
  • break is fine. You have an infinite loop, though Commented Jul 30, 2017 at 18:54
  • don't try natural language experiments with python... Commented Jul 30, 2017 at 18:55
  • 3
    if start not in ('y', 'n') is more readable, by the way Commented Jul 30, 2017 at 18:55

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.