Ministério da Educação
Brasil um país de todos
Personal tools
Navigation
Log in


Forgot your password?
 
Document Actions

slides06-ex5.py

by Cicero Garrozi last modified 2014-05-06 07:17

Click here to get the file

Size 1 kB - File type text/python-source

File contents

s = raw_input("Digite a frase: ")

cont = 0
pos = 0
while pos != -1:
    pos = s.find("ado", pos)
    if pos != -1:
        cont += 1
        pos += 3 #proxima posicao inicial da nova busca

#outra forma: cont = s.count("ado")
print "Existem %d 'ado' na frase"%cont


Powered by Plone CMS, the Open Source Content Management System

This site conforms to the following standards: