I'm very new to programming. I need to create a function that takes any string and a fill character and returns a list of 8 character strings. For example:
>>>segmentString("Hello, World!","-")
['Hello, W', 'orld!---']
As you can see, the string has 13 characters. The function splits into 2 strings, where the first contains 8 characters, and the second contains 5 characters and 3 fill characters.
So far, I've figured out how to do this for strings less than 8 characters, but not for more than 8 characters, where the string is split up, which is what I am stuck on.
def segmentString(s1,x):
while len(s1)<8:
s1+=x
return s1
How do you split a string up?