+ 1
Simple python list problem
Hi guys! I want to know how to compare all the variable of a list to another variable, I can't find that on internet... I hope you can help me, sorry my English mistakes, I'm French and my English isn't that good ^^
6 Answers
+ 3
This lesson might offer you a solution.
Check "List functions"
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2456/
+ 3
l = [1,2,3,4,5]
n2 = 2
if n2 in l:
print(n2,"is in list")
+ 2
Here's some examples:
https://code.sololearn.com/cdzvexsAdTlA/?ref=app
+ 2
That can also be done using the any function, but there is an "in" operation which does it with 3 words.
Anyways here's 3 solutions:
https://code.sololearn.com/chYqUmKNvt2m/?ref=app
+ 1
I read all the lessons and the exemple but i don't find what i search ^^
I just want to make something like that
If any item in my list == my variable
If you can explain more in details that can be great đ
Also thank for respond speedily to my message
+ 1
Thank you guys ^^ I just use "in" I didn't know that you can do that inside an if statement... But that perfectly work