0

can the user's input be saved as an array?if yes then how?

Can i let the user's input be saved as a array of integers or doubles?

14th Feb 2017, 2:40 PM
Maarouf Yassine
Maarouf Yassine - avatar
5 Respostas
+ 6
Hmm... this should work: tab = [] for i in range(10): tab.append(int(input('Add an array element: '))) print(tab)
14th Feb 2017, 2:55 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 4
C#: int[] Integers= Array.ConvertAll(Console.ReadLine().Split(' '),Int32.Parse); user input must be one line of space separated integers like this: 4 8 15 16 23 42
14th Feb 2017, 4:08 PM
HAL8999++;
HAL8999++; - avatar
+ 2
No, not at all :) Just learning...
14th Feb 2017, 5:49 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
@kuba the code u wrtoe is for ruby?
14th Feb 2017, 6:23 PM
Maarouf Yassine
Maarouf Yassine - avatar
+ 1
num = Array.new loop do puts "input a number" num.push(gets.chomp) end
22nd Feb 2017, 4:11 PM
Steven Wang
Steven Wang - avatar