def for_loop4(str, x):
result = 0
for i in str:
if i == x:
result += 1
return result
Function Call | Return Value | |||
---|---|---|---|---|
for_loop4('athenian', 'e') | → | |||
for_loop4('apples', 'a') | → | |||
for_loop4('hello', 'a') | → | |||
for_loop4('alphabet', 'h') | → | |||
for_loop4('aaaaa', 'b') | → |
Experiment with this code on Gitpod.io