a = [] a.append(A(1, "apple")) a.append(A(2, "banana")) a.sort() for i in range(len(a)): print(a[i])
Output:
2 banana 1 apple
Input
String
1 2 3
s = input() print(type(s)) sa, sb = input().split(maxsplit=1)
Output:
<class 'str'>
List
1 2 3 4 5 6
l = [] print(type(l)) l = list(map(int, input().split())) l2 = [[] for i in range(10000)] # = cpp l2 = list[10000] lm = [[[0 for i in range(3)] for j in range(4)] for k in range(5)] print(lm[4][3][2])
Output:
<class 'list'> 0
Dict
1 2
d = {} print(type(d))
Output:
<class 'dict'>
Int
1 2
n, m = map(int, input().split()) print(type(n))
Output:
<class 'int'>
Output
One line
1 2 3 4 5 6 7
n = 5 a = [] for i in range(n): a.append(i*i) for i in range(n): print(a[i],end=" " if i != n - 1 else "") print()