findall() in python

Previous
Next

findall():

  • It returns the list of duplicates in the input string for specified pattern.
  • It returns List of elements.
import re
line = "RAMAYANA AND MAHABARATHA"
arr = re.findall(r'RA',line)
print("RA found :",arr)
arr = re.findall(r'A',line)
print("A found :",arr)

Check this code:

import re
line = "This is python online session"
LIST = re.findall(r'on' , line)
print("List is : ", LIST)
print("Count : ", len(LIST))
Previous
Next

Add Comment

Courses Enquiry Form