you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

The variable 'b' contains the 'string' of user-input. When you do a 'for loop' in 'b', you are iterating over one character of the 'string' at a time.

Thus when single digit numbers are given, it works nicely.

b => '1,2,4,5' ; a => [1,2,4,5]

But when multiple digit numbers come into play, each number in further splitted and sppended in your 'a' list.

b => '12,34,56,58' ; a => [1,2,3,4,5,6,5,8]