Run
import re str = 'apple banana cherry' # Search using regex x = re.search('cherry$', str) if(x!=None): print('The line ends with \'cherry\'.') else: print('The line does not end with \'cherry\'.')
Output