How to specify list for user input? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to specify list for user input?

gilshtainFamilyNames = ["Adiel", "Liam", "Liza", "Nikolas", "Luba", "Slavic", "Euri", "Olga", "Natalie", "Viktor"] anyName = input("Hello, what is your name?") if anyName == gilshtainFamilyNames[0,9]: print("\n\n Hello " + anyName) What I want to do is, if I type any of the names which are in the list of "gilshtainFamilyNames" into the input, it will output "Hello <name in the list>". But it keeps giving me a TypeError, why?

12th Sep 2016, 12:28 PM
Nickolas Gilshtain (NickGaming)
Nickolas Gilshtain (NickGaming) - avatar
4 Answers
+ 2
if anyName in gilshtainFamilyNames:
12th Sep 2016, 12:35 PM
Zen
Zen - avatar
0
Thank you! Also another question, this (what im doing) is a good way to practice python?
12th Sep 2016, 12:38 PM
Nickolas Gilshtain (NickGaming)
Nickolas Gilshtain (NickGaming) - avatar
0
Yep it is i also try and practice python the same way
12th Sep 2016, 1:02 PM
steampunk08
steampunk08 - avatar
0
i like making my own simple console to practise
12th Sep 2016, 1:03 PM
steampunk08
steampunk08 - avatar