|
#! /usr/bin/python list1 = ['arr', 'bre', 'grau', 'lower', 'tudo'] for item in list1: if item == 'arr' or item == 'grau': print list1 Hopefully, my rewording of one of your tests will make it a bit easier to see what is happening. A for statement such as 'for item in list1' walks the whole list. Therefore, every iteration is tested. Notice you are doing two tests in one if statement so that each time a true condition happens during the iterations that list will print. You have two iterations that get a true result so list1 prints twice. That should clear up the confusion. If not please tel us what is still not clear. Robert Berman Eduardo Vieira wrote:
|
_______________________________________________ Tutor maillist - [email protected] http://mail.python.org/mailman/listinfo/tutor
