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)
2 Antworten
+ 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.
+ 1
s = "111001"
l = []
for i in range(0, len(s), 2):
l.append(s[i:i + 2])
l #["11", "10", "01"]