Hi, so I was trying to write a solution using split as hinted. So I came up with this and it seems to work. I later realised looking at the solution given that I actually didn’t really need the “gap” variable. So now I’m confused. Do I actually need to use the split function to solve this problem or is it just for the practice? Cos it seems more complicated than it really needs to be. Also, does my solution actually work (usable) or was it just a fluke? I’d appreciate any feedback.
Btw I’m new and still learning how to copy codes in here. If the indentation comes out funny it’s because I didn’t know how to do it but it is indented in the correct place.
> def count_multi_char_x(word, x): > **gap = word.split(x)** > count = word.count(x) > return count
should print 2
should print 1
> def count_multi_char_x(word, x): > splits = word.split(x) > return(len(splits)-1)