0

Hey im trying to have it sort through these names.

When i type Tanner it says yser not found only because i didnt type the other names is there a way to have it be satisfied if it at leasts funds one name match. Thanks!! Here us the code. var1 = "Bob" var2 = "Tanner" var3 = "Jake" var4 = "Mike" var5 = "Chris" var = { '1': "Bob", '2': "Tanner", '3': "Jake", '4': "Mike", '5': "Chris" } question = input('What is your name? ') if question == var1: print('\nWelcome Back Bob') if question == var2: print('\nWelcome Back Tanner!') if question == var3: print('\nWelcome back Jake!') if question == var4: print('\nWelcome Back Mike!') if question == var5: print('\nWelcome Back Chris!') if question != var print('\nUser Not Found!')

29th Sep 2017, 2:54 AM
Tanner
1 ответ
+ 2
You can just make a list of the users and then check if the user is in the list. users = ["Bob", "Tanner", "Jake", "Mike", "Chris"] name = input("What is your name? ") print() if name in users: print("Welcome back {}".format(name)) else: print("User not found!")
29th Sep 2017, 3:04 AM
ChaoticDawg
ChaoticDawg - avatar