0

So my listname is men =[]

How can i print just the 10 first elements of the list? It contains 15...
And it's a matrix...

I thought about making a while-loop while i > 9: but it didn't work.

Can anybody help me please? :)

for gender in men:
            print gender[0] + " " + gender[1] + "\t""\t"" " + gender[2] + "\t" + 
            gender[3] + "\t" , gender[10]
3
Contributors
3
Replies
4
Views
7 Years
Discussion Span
Last Post by goisagi
0

hi,
you could do something like this:

men = [ [ 1 ], [ 2 ], [ 3 ], [ 4 ], [ 5 ], [ 6 ], [ 7 ], [ 8 ], [ 9 ], [ 10 ], [ 11 ], [ 12 ], [ 13 ], [ 14 ], [ 15 ] ]
for gender in men[ :10 ]:
	print gender

# Output:
"""[1]
[2]
[3]
[4]
[5]
[6]
[7]
[8]
[9]
[10]"""

I'm not sure whether the format of the list I'm using is the same as the one you specified, so pls. correct me if this is not right.

hope this helps :)

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.