Making Faces

Before there were emoji, there were emoticons, whereby text like :) was a happy face and text like :( was a sad face. Nowadays, programs tend to convert emoticons to emoji automatically!

In a file called faces.py, implement a function called convert that accepts a str as input and returns that same input with any :) converted to ๐Ÿ™‚ (otherwise known as a slightly smiling face) and any :( converted to ๐Ÿ™ (otherwise known as a slightly frowning face). All other text should be returned unchanged.

Then, in that same file, implement a function called main that prompts the user for input, calls convert on that input, and prints the result. Youโ€™re welcome, but not required, to prompt the user explicitly, as by passing a str of your own as an argument to input. Be sure to call main at the bottom of your file.

Hints

Before You Begin

Execute cd by itself in your terminal window. You should find that your terminal windowโ€™s prompt resembles the below:

$

Next execute

mkdir faces

to make a folder called faces in your codespace.

Then execute

cd faces

to change directories into that folder. You should now see your terminal prompt as faces/ $. You can now execute

code faces.py

to make a file called faces.py where youโ€™ll write your program.

Demo

How to Test

Hereโ€™s how to test your code manually:

  • Run your program with python faces.py. Type Hello :) and press Enter. Your program should output:
    Hello ๐Ÿ™‚
    
  • Run your program with python faces.py. Type Goodbye :( and press Enter. Your program should output:
    Goodbye ๐Ÿ™
    
  • Run your program with python faces.py. Type Hello :) Goodbye :( and press Enter. Your program should output
    Hello ๐Ÿ™‚ Goodbye ๐Ÿ™