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