If you want to express it as an array of NumPy, it can be converted with np.array (), so it will be omitted.
NumPy array
l = [[1, 2, 3], [4, 5, 6]]
l = np.array(l)
# l = [[1 2 3][4 5 6]]
input | code | Remarks |
---|---|---|
a | s = input() | |
1 | s = int(input()) | |
a b c | s = list(input().split()) x, y, z = input().split() |
|
1 2 3 | n = list(map(int, input().split())) x, y, z = input().split() |
|
3 a b c |
n = int(input()) l = [input() for i in range(n)] |
|
3 1 2 3 |
n = int(input()) l = [int(input()) for i in range(n)] |
|
2 3 a b c d e f |
n, m = map(int, input().split()) l = [list(input().split()) for i in range(n)] --- n, m = map(int, input().split()) l = sum([list(input().split()) for i in range(n)], []) |
Nested and flat format |
2 3 1 2 3 4 5 6 |
n, m = map(int, input().split()) l = [list(map(int, input().split())) for i in range(n)] --- n, m = map(int, input().split()) l = sum([list(map(int, input().split())) for i in range(n)], []) |
|
3 2 1 a 2 b 3 c |
n, m = map(int, input().split()) l = [] for i in range(n): x, y = input().split() l.append([int(x), y]) |
|
3 1 2 3 4 5 6 7 8 9 10 11 12 |
n = int(input()) l = [list(map(int, input().split())) for i in range(n)] graph = {} for i in range(n): graph.setdefault(str(l[i][0]), []).append(l[i][1:]) print(graph) |
Get in graph format |
Recommended Posts