what can I do if I want to check every item in a list without using a lot of if-statments
The code:
a = 1
b = 1
c = 1
letters = [a , b , c]
if letters == 1:
print("same")
else:
print("not same")
apparently what happens that I am comparing a list
to an int
which are completely different.
I have tried this using a for-loop
but it checks every item individually and print me the result for each item individually.
The code:
a = 1
b = 1
c = 1
letters = [a , b , c]
for letter in letters:
if letter == 1:
print("same")
else:
print("Not same")
I know that it can be solved using this method:
a = 1
b = 1
c = 1
if a == 1 and b == 1 and c == 1:
print("same")
else:
print("not same")
But it is very time consuming especially when you have got a lot of items.