I have to create a function that takes a message the user wants to encrypt and returns the encrypted string. The encryption follows a set of rules:
- Character: In the alphabet and uppercase [A-Z], Replace with: Lowercase character and add a ^ character afterwards
- Character: In the alphabet and lowercase [a-z], Replace with: Do not change
- Character: 1, Replace with: @
- Character: 2, Replace with: #
- Character: 3, Replace with: $
- Character: Any other character, Replace with: *
This is my code so far. It'll only return 'p^', so I figured something is wrong with my first if statement and the return value. If someone could steer me in the right direction I'd appreciate it!
def encryptMessage(secretMsg):
secretMsg = str(secretMsg)
u = secretMsg.upper()
symbol = "^"
for x in secretMsg:
    if u in secretMsg:
        return u.lower() + symbol
        secretMsg += x
    return secretMsg
    if u.lower():
        return secretMsg
    elif 1 in secretMsg:
        return secretMsg.replace(1, "@")
    elif 2 in secretMsg:
        return secretMsg.replace(2, "#")
    elif 3 in secretMsg:
        return secretMsg.replace(3, "$")
    num = u > 3
    if num in secretMsg:
        return secretMsg.replace(num, "*")
return secretMsg
Examples:
Note: These are examples of what the program should return, not actual instances of the program running.
>>> encryptMessage("my123password")
'my@#$password'
>>> encryptMessage("Dan()123Barrun")
'd^an**@#$b^arrun'
>>> encryptMessage("PASS99cats")
'p^a^s^s^**cats'
 
    