I am trying to find the number of times the letter "s" appears in the word "Mississippi". Why doesn't my code work? I should get an output of 4.
def find(word,letter):
index=0
while index <len(word):
if word[index]==letter:
return index
index=index
print (index)
find("mississippi", "s")
I think you didn't added the counter, and the index isn't increasing. I reworked your code: