Jak OT dzieli sznur co czwarty eter
>>> line = '1234567890'
>>> n = 2
>>> [line[i:i+n] for i in range(0, len(line), n)]
['12', '34', '56', '78', '90']
Successful Swiftlet
>>> line = '1234567890'
>>> n = 2
>>> [line[i:i+n] for i in range(0, len(line), n)]
['12', '34', '56', '78', '90']
a_string = "abcde"
n = 2
split_strings = [a_string[index : index + n] for index in range(0, len(a_string), n)]
def split(word):
return [char for char in word]
# Python3 code to demonstrate working of
# Splitting operators in String
# Using re.split()
import re
# initializing string
data = "GeeksforGeeks, is_an-awesome ! website"
# printing original string
print("The original string is : " + data)
# Using re.split()
# Splitting characters in String
res = re.split(', |_|-|!', data)
# printing result
print("The list after performing split functionality : " + str(res))
s = '1234567890'
o = []
while s:
o.append(s[:2])
s = s[2:]
def splitString(s):
if len(s)%2 ==0:
num=2
split_string= [s[i:i+num] for i in range(0, len(s), num]
return split_string
elif len(s)%2 !=0:
newstring=s+"_"
num = 2
split_string= [newstring[i:i+num]for i in range(0, len(newstring),num)]
return split_string
splitString("Godwin")
splitString("wekesa")