Programming with Python, Unit 4/Week 6, Day 4


I’m having issues understanding Question # 4 Count Multi- X in the String Methods Code Challenge. I was struggling with this problem quite a bit and I looked at the solution to see how far off my answer was. Here’s the solution
def count_multi_char_x(word, x):
splits = word.split(x)

If you enter this in:
print(count_multi_char_x(“mississippi”, “iss”))

Why does it give you 2?

wouldn’t splits = [‘m’, ‘ippi’] so the length of splits would be 2 - 1 would be 1…so why is this printing 2?


In fact, splits will be, ['m', '', 'ippi'] which has lengh of 3.