1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] Need steps for a basic python loop question

Discussão em 'Python' iniciado por Stack, Agosto 22, 2025.

  1. Stack

    Stack Membro Participativo

    I am a complete noob to programming so excuse the ignorance. I am taking a MOOC and can't for the life of me figure out what steps to take to solve this problem:

    Assume s is a string of lower case characters.

    Write a program that prints the number of times the string 'bob' occurs in s. For example, if s = 'azcbobobegghakl', then your program should print

    Number of times bob occurs is: 2

    OK. I know that a for loop is necessary. I think it should start with:

    x=bob
    count=0
    for count in range(s):
    >if


    Here I am not sure how to retrieve the specific word 'bob' from the index, and I know I need to enter count+=1 but am not sure where. Could someone please help me? I am sure I could solve this on myself but I am getting frustrated after a few hours!

    Continue reading...

Compartilhe esta Página