[BangPypers] Iterating list of tuples
Venkatraman S
venkat83 at gmail.com
Mon Jul 4 08:36:27 CEST 2011
On Mon, Jul 4, 2011 at 11:54 AM, Asif Jamadar <asif.jamadar at rezayat.net>wrote:
> 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"
> else:
> print "lesser"
>
> But the code giving me error so can I know how iterate list of tuples?
>
for tup in data:
for x in tup:
if x> 5:
print x, ':greater'
else:
print x, ':lesser'
Also, check if you can use 'any'.
-V
More information about the BangPypers
mailing list