How can we store " 1 2 3 4 5 " in an array when they are separated by space as [1,2,3,4,5]
str
type has helpful method split()
, that can create array from string. Keep in mind that you still will need to change type of each element from str
to int
.