-2

I tryed to make a Verification system, but it dont really Works well.

If i choose username Fynn or LeQuit this ist the output

Welcome Fynn

You are not LeQuit or Fynn

But its not what i need i need it to choose 1, Like if i type a random name Example:dfgdfdfgd

it still says the Same...

My code

if username == "LeQuit" or "Fynn":
    print("Welcome " + username)
if not username == "LeQuit" or "Fynn":
    print("You are not LeQuit or Fynn ")
LeQuit
  • 47
  • 1
  • 9
  • 1
    `if username in {"LeQuit", "Fynn"}` and `if username not in {"LeQuit", "Fynn"}`. But in that code better to use `else`. – Olvin Roght Oct 31 '20 at 11:45
  • Does this answer your question? [How to check variable against 2 possible values?](https://stackoverflow.com/q/3260057/2745495) – Gino Mempin Oct 31 '20 at 11:52

2 Answers2

2

Your haven't used the or correctly. Here is the correct code:

if username == "LeQuit" or username == "Fynn":
    print("Welcome " + username)
else:
    print("You are not LeQuit or Fynn ")
Sushil
  • 5,440
  • 1
  • 8
  • 26
  • 1
    Thank you Very much, i cant mark this answer as Helpful i have to wait 7 minutes, but i gonna definitly do it :D – LeQuit Oct 31 '20 at 11:51
0

If you have many users in your system - the code below is the right way to go.
It keeps the users in a set and check against the set

registered_users = {"LeQuit","Fynn","Other users..."}
if username in registered_users: 
    print(f"Welcome {username}")
else:
    print("f{username} is not a registered user")
balderman
  • 22,927
  • 7
  • 34
  • 52