0
Checking multiple items in List
So I’m running my own list in idle with 4 names. I am able to use the in function to check a name but I am not sure how to have three print lines to check multiple names in my list. https://code.sololearn.com/c3dEU5AziL0r/?ref=app
4 Respuestas
+ 2
Question doesn't seem to very clear. Do you mean you just want to print all those names from the list? If yes, then you can use for loop with a print() inside. If not then kindly provide the code snippet for same to get better help from the community.
+ 2
Save the code in a *.py file and open it with IDLE
+ 1
names = list with names
print(any(name in names for name in ('name1', 'name2', 'name3')))
Or:
for name in ('name1', 'name2', 'name3'):
if name in names:
print(name)
0
I didnt word the question that good. What im asking is extremly simple but I simply dont know how to do it. In the code I posted, there is a list. Underneath the list are three print lines checking values inside my list. When I run the code on idle, I only have the option to tab down and print one value. I want to know how to have 4 lines of code in total with three print prompts.