Python vector read | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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?

3rd Aug 2019, 2:24 PM
~ ź¼°ģŠ¤ķƒ„ķ‹“ ģ˜¤ė‹ˆģ”ø ~
~ ź¼°ģŠ¤ķƒ„ķ‹“ ģ˜¤ė‹ˆģ”ø ~ - avatar
1 Resposta
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)
3rd Aug 2019, 11:21 PM
Steven M
Steven M - avatar