& 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())
Comments
Leave a comment