CP104 Lecture 7: 2D List
![](https://new-preview-html.oneclass.com/rBRgqlv0YP2XQykxB9OYj5V9M6zyxZLD/bg1.png)
Last Two Questions two D lists
- 2d matrix
- Group data together with one name and use indexing to access element
- List triangular
- Nested for loops to print elements of two d lists
- Initialize list with empty list and append and put into two d list
- result=[]
- temp=[]
- result.append(temp)
- #Append empty lists in first two indexes.
- elements.append([])
Need to specify what empty list to put inside
Ways to fill two d lists
- results=[][
- For i in range (3):
- results.append([]) or temp=[]
- For j in range (3):
- Temp.append (0)
result.append(temp)
- Find highest number in 2d list
- Other list initialized two for loops
>> get average of rows and columns (separate)
Def get_av(handle_n):
rows=int(handle_in.readline())
cols= int(handle_in.readline())
std_2d=[]
For r in range(rows):
![CP104 Full Course Notes](https://new-docs-thumbs.oneclass.com/doc_thumbnails/list_view/2140001-class-notes-ca-wlu-cp104-lecture3.jpg)
2
CP104 Full Course Notes
Verified Note
2 documents