How to call a function if input is not one of a list of names? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to call a function if input is not one of a list of names?

Hi, I’m working on a python3 software and I have a question: How to call a function if input is not one of a list of names? For example: PYTHON3 def menu(): Blank a = input(“What’s your name?:”); names = [‘blank’,’blank1’,’blank2’] So how do I call the function menu() if a is not one of the names?

7th Dec 2019, 8:28 AM
Priel
Priel - avatar
3 Answers
+ 3
if a not in names: menu()
7th Dec 2019, 8:58 AM
HonFu
HonFu - avatar
7th Dec 2019, 9:13 AM
Nomeh Uchenna Gabriel
Nomeh Uchenna Gabriel - avatar
+ 1
Thank you!
7th Dec 2019, 9:41 AM
Priel
Priel - avatar