import re #The search() function returns a Match object: txt = "The rain in Spain" x = re.search("ai", txt) print(x)