10 Searching in a list:-
Create a list named my_list and input 5 numbers in the list, input a number named val and check whether that number exist in the list or not. For example
My_list= 90,34,5,33,55
Val= 34
Output:- Yes
Val= 100
Output:- No
Answers
Answered by
5
The following cσdes have been written using Python.
my_list = list()
for i in range(5):
x = int(input("Enter a number: "))
my_list.append(x)
print()
print()
print(my_list, "is your given list.")
print()
val = int(input("Enter a number you'd like to check for: "))
if val in my_list:
print("Yes")
else:
print("No")
Similar questions