Is there a way to write an if statement that will pick up duplicates (two ‘1’s):

L = ['1', '4', '1']
if (L[0]) != (L[1]) != (L[2]):
    print "THEY ARE NOT EQUAL"
else:
    print "THEY ARE EQUAL"

When I run this code, it prints “THEY ARE NOT EQUAL” when it should print the 
else “THEY ARE EQUAL”.

list L has two ‘1’s; therefore I am trying to get an if statement that will 
recognize this. When using the != (not equal) operator, shouldn’t the if be 
true when items in list are not the same? Any input would be appreciated.

Thanks,

Greg
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to