[BangPypers] Iterating list of tuples
noufal at gmail.com
Mon Jul 4 08:31:14 CEST 2011
Asif Jamadar <asif.jamadar at rezayat.net> writes:
> Suppose I have list of tuples
> data = [
> (10, 25, 18, 17, 10, 12, 26, 5),
> for value in data:
> if data[value]>5:
> print " greater"
> print "lesser"
if the list has just one tuple, you need to iterate over it's individual
for i in data: # Iterate over elements of the tuple
if i > 5:
`value` in your code does not mean the index, it's the actual element
I'm proud of my humility.
More information about the BangPypers