0
Python vector read
How can I read a vector without knowing any element before? I mean, if I want to read these numbers: 1 5 2 3 100 how can I read it? It’s a good option to read like this? : a, b, c, d, e = map(int, input().split()) from vector import* vector = (“i”, [a, b, c, d, e]) In C++ simply use while loop: i = 0; while(cin >> a) vector[i++] = a; But in python?
1 ответ
0
#Something like this?
def vector(*values):
i=0
for each in values:
flags=dict.fromkeys([chr(97+i)], values[i])
print(flags)
i+=1
values=[1,5,3,2,100]
vector(*values)