October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PCOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

CS50P “Making Faces”: How to Think Through the Python Exercise

CS50P’s Making Faces exercise asks you to replace two emoticons while preserving the rest of the input. Here’s how to reason through convert, main, and the required checks.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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

  1. main obtains a string from the user.
  2. main passes that string to convert.
  3. convert returns a transformed string.
  4. main prints 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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

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.

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.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

check50 cs50/problems/2022/python/faces

Common mistakes to avoid

  • Printing inside convert instead of returning: the function’s job is to return the changed string; main prints 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.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

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.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.