Answer to Question #3388 in Python for mukunda

Question #3388
& Text = “Python is a multi-paradigm programming language. Rather than forcing programmers to adopt a particular style of programming, it permits several styles: object-oriented programming and structured programming are fully supported, and there are a number of language features which support functional programming and aspect-oriented programming (including by meta programming and by magic methods).
Many other paradigms are supported using extensions, such as pyDBC and Contracts for Python which allow Design by Contract”
Search = “pro”
Write a python program to find all occurrences of string ‘Search’ in a given string ‘Text
1
Expert's answer
2011-08-02T14:18:59-0400
import re

text = """
Python is a multi-paradigm programming language. Rather than forcing programmers to adopt a particular style of programming, it permits several styles: object-oriented programming and structured programming are fully supported, and there are a number of language features which support functional programming and aspect-oriented programming (including by meta programming and by magic methods
Many other paradigms are supported using extensions, such as pyDBC and Contracts for Python which allow Design by Contract
"""

search = "pro"

for m in re.finditer (search, text):
print(search, "is at position", m.start())

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS