import re text1 = 'I love mama so much'result = 'Nice' if re.search(r"\bmama\b", text1) else text1print(result)
Standard input is empty
Nice
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!