0

Just a normal question

Hello people, I want to separate a serie of string numbers in pairs. How can I do it? (111001 to 11 10 01)

18th Sep 2020, 5:24 PM
âšĄđŸ”„ 😎 Baby Hater đŸ”„âšĄ
âšĄđŸ”„ 😎 Baby Hater đŸ”„âšĄ - avatar
2 Answers
+ 3
Create an empty list. Iterate through the string with an index variable with a step of 2. On each iteration slice the string from the index variable to the index varisble + 1 and append the slice to the list.
18th Sep 2020, 5:40 PM
Seb TheS
Seb TheS - avatar
+ 1
s = "111001" l = [] for i in range(0, len(s), 2): l.append(s[i:i + 2]) l #["11", "10", "01"]
19th Sep 2020, 2:11 AM
Seb TheS
Seb TheS - avatar