← Back to challenges

Emotify the Sentence

PythonHardconditionslanguage_fundamentalsstringsformatting

Instructions

Create a function that changes specific words into emoticons. Given a sentence as a string, replace the words smile, grin, sad and mad with their corresponding emoticons.

wordemoticon
smile:D
grin:)
sad:(
mad:P

Examples

emotify("Make me smile") ➞ "Make me :D"

emotify("Make me grin") ➞ "Make me :)"

emotify("Make me sad") ➞ "Make me :("

Notes

  • The sentence always starts with "Make me".
  • Try to solve this without using conditional statements like if/else.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Video Length in Seconds