0
How can i check list on python
This is my example and I want to check list like this. List1= [âaâ,âbâ,âcâ] List2= [âaâ,âbâ,âcâ] count=0 I want to check my list like this List1=[âaâ]==list2=[âaâ] if false count=count+1 and do it again list1=[âbâ]==list2=[âbâ] until the end of list1 Thank you for help
2 RĂ©ponses
+ 2
There are several ways you could structure a loop in Python to accomplish this. Here's an example of 1.
count = 0
for i in range(len(list1)):
if list1[i] != list2[i]:
# increment count when
# elements don't match
count += 1
else:
... # code when they do match
You can change the comparison operator to == to flip the if statement around etc. This loop, of course, assumes that list1 and list2 have the same length.
+ 1
Thank you very much