Question: Write a function that takes a username as input and replaces certain characters with digits or special characters that resemble them visually. However, replacements should

Write a function that takes a username as input and replaces certain characters with digits or special characters that resemble them visually. However, replacements should only be made on the even occurrence of those characters in the username, not the odd occurrences. In other words, the first time you see a character that can be replaced, we won't change it. The second time you see a character that can be replaced, you should, and so on. Note that the input will always be lower-cased.
Arguments:
- username (type: str): The input username.
Returns:
- fancy_username (type: str): The modified username with replacements made.
Character Mappings:
a -> @
e ->3
i ->1
o ->0
s -> $
g ->9
b ->6
Examples:
create_fancy_username(username): us3rnam3
create_fancy_username(association): a$s0ci@ti0n
create_fancy_username(mississippi): mi$s1s$ipp1
Starting code:
def create_fancy_username(username: str)-> str:

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!