In CS50P’s “Making Faces” exercise, write convert to return a string with every :) replaced by 🙂 and every :( replaced by 🙁. Then write main to read input, pass it to convert, and print the returned string. Any text that is not one of those two emoticons should stay as it is.
What the program needs to do
The assignment separates the work into two functions. convert handles the string transformation; main handles interaction with the user and displays the result. The key distinction is that convert returns a value—it does not need to print anything.
:)becomes 🙂.:(becomes 🙁.- All other characters, including spaces and punctuation, remain unchanged.
The official CS50 assignment page notes that an emoji is a character and can be written in Python as a string, for example "😐". You can therefore use the requested emoji characters directly in your code.
How to trace the input through the functions
mainobtains a string from the user.mainpasses that string toconvert.convertreturns a transformed string.mainprints that returned string.
This separation makes the contract easy to check: give convert a string, and it should give back the corresponding string with both substitutions made. The assignment allows an explicit input prompt, but does not require one.
Free tools Windows power users keep installed
One-click scans. No signup required.
#1 Best Overall
Check the required transformations
CS50’s assignment page gives these manual examples:
| Input | Expected output |
|---|---|
Hello :) |
Hello 🙂 |
Goodbye :( |
Goodbye 🙁 |
Hello :) Goodbye :( |
Hello 🙂 Goodbye 🙁 |
The combined example matters: the function must handle both target strings in the same input. The surrounding words and spacing should survive the conversion.
Rank #2
Create and run the file
The assignment suggests creating a faces directory and saving the program as faces.py. Its suggested run command is python faces.py. The broader Problem Set 0 page describes cs50.dev as a cloud-based VS Code environment with course tools installed.
After trying the manual examples, the assignment page lists this automated check command:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
check50 cs50/problems/2022/python/faces
Common mistakes to avoid
- Printing inside
convertinstead of returning: the function’s job is to return the changed string;mainprints it. - Handling only one emoticon: both
:)and:(must be converted, including when both occur in one string. - Rebuilding the whole sentence: only the target emoticons should change; preserve the rest of the input.
- Assuming a prompt is required: a prompt is optional; reading input, converting it, and outputting the result are the essential steps.
Check the course deadline on the live page
The current CS50 Problem Set 0 page lists a deadline of December 31, 2026, at 23:59 UTC. Deadlines can change, so check the official Problem Set 0 page before relying on that date.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




