id/email
password
forgot password | create account
about | help | prefs
ReadingBatcode reading practice

 

 

For Loopsfor_loop6

prev  |  next  |  chance
def for_loop6(str, x):
    result = 0
    xl = len(x)
    strl = len(str)
    for i in range(strl - xl + 1):
        if str[i: i + xl] == x:
            result += 1
    return result
Function Call  Return Value
for_loop6('athenian', 'e')
for_loop6('apples', 'ap')
for_loop6('hello', 'a')
for_loop6('alphabet', 'al')
for_loop6('aaaaa', 'aa')
for_loop6('computational thinking', 'in')
for_loop6('hello goodbye hello', 'hello')

Experiment with this code on Gitpod.io

⬅ Back