find a pattern in python string code example
Example 1: searching for a pattern in text with re python
import re
xx = "guru99,education is fun"
r1 = re.findall(r"^\w+",xx)
print(r1)
Example 2: pattern in python
rows = 6 #Pattern(1,121,12321,1234321,123454321)
for i in range(1, rows + 1):
for j in range(1, i - 1):
print(j, end=" ")
for j in range(i - 1, 0, -1):
print(j, end=" ")
print()