I want to know how to make an if statement that executes a clause if a certain integer is in a list.
All the other answers I've seen ask for a specific condition like prime numbers, duplicates, etc. and I could not glean the solution to my problem from the others.
You could simply use the in keyword. Like this :
in
if number_you_are_looking_for in list: # your code here
For instance :
myList = [1,2,3,4,5] if 3 in myList: print("3 is present")
1.4m articles
1.4m replys
5 comments
57.0k users