-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path2D_Array.py
More file actions
40 lines (34 loc) · 1.01 KB
/
2D_Array.py
File metadata and controls
40 lines (34 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
"""
@Author: Ghouri Iqbal Khan
@Date: 2022-07-12 14:57
@Last Modified by: Ghouri Iqbal Khan
@Last Modified time: 2022-07-12 14:57
@Title : Print 2D array
"""
def display_array(rows, columns):
"""
Description:
adding values in 2D Array
Parameter:
Rows and Columns
Return:
2D_Array values
"""
row_values = []
for i in range(0, rows):
column_values = []
for j in range(0, columns):
print("Enter the {} {} th element".format(i, j))
array_input = int(input())
column_values.append(array_input)
row_values.append(column_values)
return row_values
if __name__ == "__main__":
try:
row = int(input("Enter number of rows : "))
column = int(input("Enter number of columns : "))
array_element = display_array(row, column)
for i in range(len(array_element)):
print(array_element[i])
except Exception as e:
print("Enter correct input", e)