-2

I'm making a YouTube MP3 Downloader, so I'm giving two options to user, is it MP3, or MP4? And the user can only respond with these 2 answers, if user responds with another thing, like "unicorn" instead of "mp3" or "mp4", user will get an error. But if user will write "mp3" or "mp4", it will work correctly. I tried this:

if not fileFormat == "mp3" or "mp4":
    print("Error!")
else:
    print("Correct!")

But it's not working. How can I fix it?

Deliable
  • 23
  • 1
  • 6

1 Answers1

1

For such things, I like to use the (not) in options

if fileFormat.lower() not in ["mp3", "mp4"]:
    print("Error!")
else:
    print("Correct!")

Emil105
  • 160
  • 6
  • 1
    Hello! I see you're new here. When questions are duplicates of previously asked questions, we prefer to close and link them rather than post the same answers over and over again. When you see a question about something fundamental like this, it's usually been asked [before](https://stackoverflow.com/questions/15112125/how-to-test-multiple-variables-for-equality-against-a-single-value). – CrazyChucky Jan 09 '22 at 16:12