How to loop over Lists of lists in Python

3 Answers

0 votes
list_of_lists = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
for one_list in list_of_lists:
    for i in one_list:
        print(i)


'''
run:

1
2
3
4
5
6
7
8
9

'''

 



answered Oct 14, 2017 by avibootz
0 votes
list_of_lists = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
for one_list in list_of_lists:
    for i in one_list:
        print(i, end=" ")


'''
run:

1 2 3 4 5 6 7 8 9

'''

 



answered Oct 14, 2017 by avibootz
0 votes
list_of_lists = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
for one_list in list_of_lists:
    for i in one_list:
        print(i, end=" ")
    print()

'''
run:

1 2 3
4 5 6
7 8 9

'''

 



answered Oct 14, 2017 by avibootz

Related questions

1 answer 121 views
1 answer 179 views
2 answers 218 views
1 answer 129 views
2 answers 225 views
2 answers 171 views
...