Listing 07-01: Search for all occurrences

##############################################################################
# Python From Scratch
# Autor: Nilo Ney Coutinho Menezes
# Editora Novatec (c) 2010-2024
# Site: https://pythonfromscratch.com
#
# File: listing\chapter 07\07.01 - Search for all occurrences.py
# Description: Search for all occurrences
##############################################################################

s = "one tiger, two tigers, three tigers"
p = 0
while(p > -1):
    p = s.find("tiger", p)
    if p >= 0:
        print("Position: {p}")
        p += 1
Click here to download the file