jobmatt...@gmail.com wrote: > for item, i in enumerate(aa) > print item > > this writing, it can print all values > > for item, i in enumerate(aa) > if item == findit: > print item > > this only print the first value, means it only print once then not print > again,
Assuming aa = ["foo", "bar", "baz"] and findit = "bar" the print statement will only be executed when findit == item. First iteration of your for loop: item = "foo" if "foo" == "bar": # False print "foo" # not executed, nothing printed Second iteration: item = "bar" if "bar" == "bar": # True print "bar" # prints bar Third iteration: item = "baz" if "baz" == "bar": # False print "baz" # not executed, nothing printed > where is wrong? This depends on what you want to achieve. Can you tell us? -- https://mail.python.org/mailman/listinfo/python-list