Skip to main content

Command Palette

Search for a command to run...

Cracking CS50P: Thinking Through "Making Faces"

Beyond the code: How a simple string-replacement problem in Week 0 highlights the importance of user experience and emotional tone in software.

Updated
3 min readView as Markdown
Cracking CS50P: Thinking Through "Making Faces"
D
Built with the support of AI collaboration.

Welcome back to my new series of "Cracking CS50P: A DevAdvocate's Python Guide", today we are going to dive into how I tackled the third problem in Problem Set 0: "Making Faces" (faces.py).

If you didn't read the previous article I mean Playback Speed or playback.py then trust me you are missing the important detail in the python language. And as you know I am here to guide you in how to solve the problems I am not telling the exact answers to any problem set because you have to learn it by yourself.

Recap of 2nd Article playback.py........

In the previous article we saw how to replace any "str" to something we want it to replace in to. But only if it's a string not a number or a float or etc., Note this one out this is a thing anyone could forget about OK.....
This article is also the same as the previous one but this time we have to replace the more than one str into something so it's going to be intresting so hang on tight.
Let me tell you a secret, As the first and the second mistake I misunderstood this one too and print out the exact statement like given in the example section. (e.g."Hello 🙂") It is so funny I couldn't resist after realizing that and I begin to laugh.....

Let's start 3rd Article faces.py........

In this part we are going to see that how to instruct the system to replace more than one string to something else. Let's get started, In previous part we use .replace( ) syntax in this part we can use this syntax and other syntax too. So, for this we can use "n" number of .replace( ) syntax for "n" number of replacements like [.replace("/", "?").replace("_", "=")] in this case we are replacing( / to ? and _ to = ) and also we can use a variable to assign the values of replacements and use
```python
for target, emoji in replacements.items():
user_text = user_text.replace(target, emoji)
***```*
**from this we can use only one function and still get the value as the previous syntax.
So, I guess that's it for today if any has any doubt feel free to ask in the comment and if not then you can see the YouTube lecture video on my channel. See you all in the next article of CS50 intro to Python.

Cracking CS50P: A DevAdvocate’s Guide

Part 3 of 3

Documentation of my journey through Harvard's CS50P. Instead of giving away solutions, this series breaks down core Python concepts, translates tricky error codes, and provides logical hints to help you solve the problem sets yourself.

Start from the beginning

Beyond the Syntax: What CS50P’s "Indoor Voice" Teaches Us About Developer Empath

Why the foundational law of software engineering isn't about writing complex algorithms—it's about handling human unpredictability gracefully.