I have lost the upper case! 😢

Hi Guys! I’m working on the censor dispenser project and I got stuck! I had to format a string (a) in lower case. Now, after a few “for loops”, I need to return this new string (b) (which has the same text of string (a)) with the original upper and lower case in string (a). I know! For almost all of you this may seem such a stupid thing but I’ve been studying python for less than a month and solution for things like this can be harder to find!:wink: Thanks!!!

Any chance you could save your first string to an extra variable before formatting it so you can use it later?

Here is my code ( It doesn’t look great! I know! :sweat_smile:):

At this point the result of email2 should be exactly the same string in email but with censored words (apart from the first). It seem to work fine. But email2 is returned without punctuation and in lower case format! I have not idea how to put the punctuation back and replace the upper case as in email!

If you can do it manually, by hand, then you have an idea of how to do it.

What do you mean …? :thinking:
I think the solution is to use something that I haven’t come across yet so far. When I try, many times looks like I’m about to see the light at the end of the tunnel. Then when I get there I realize that I’m still missing something!

If you write down the original and your censored text on paper, how do you restore punctuation and capitalization?
You already know how to do it. You’re just detaching yourself from your ability to reason about your problem using every day logic because you’re writing code.

I agree with @ionatan, but I would also add that it’s important to think of your code as steps you are telling your computer to take. If you give it the wrong steps, leave steps out, or provide the steps in the wrong order, you won’t get what you want.

Keeping that in mind, write down a list of the steps the computer needs to take in order to do what you want it to do — no code, just plain words! Then, take a look at that list, make sure it’s in the right order and you didn’t leave anything out. Now you can finally think about what code it takes to accomplish each of those steps.