CODE CHALLENGE: STRING METHODS function

For this exercise, the hint suggests using the split function and getting the amount of times the word is split to count the times that the string was in the input.

I used the following code, is there anything wrong with this?

def count_multi_char_x(word, x):
return word.count(x)

Link to exercise:
https://www.codecademy.com/paths/data-science/tracks/dscp-python-fundamentals/modules/dscp-python-strings/lessons/python-functions-strings-cc/exercises/countx-ii

First time on the forum as well :slight_smile:

Hello!
Does it work, and does it work for the right reasons ? If yes, then there’s nothing wrong with it - though sometimes the lesson wont let you advance if you don’t do it as they suggest.

You might want to have a go using split just for practice. It might come in useful at some point.