Hi,
I need to create an array from string.
Array should have two digit consistent fragments.
For example if
s="10886"
I should have [10, 8, 88, 86]
Can anyone help me with this
What parts are you having trouble with? Have you tried anything so far? Show us the code for your attempt.
Can't figure it out how to get two digit consistent from string. I made this but it is returning 2 by 2 digit which is not what I wanted
[int(s[i:i+2]) for i in range(0, len(s), 2) ]
In the range statement, you're skipping by 2s. But you really want to go by 1s, just making sure you stop 1 before the end (since you don't want to ask for the n and n+1 characters).
If you get rid of the last 2 in your range...
s='10886'
[int(s[i:i+2]) for i in range(0, len(s)) ]
Output:
[10, 8, 88, 86, 6]