In your original code, the return was inside the "for" loop, so it returned after only one iteration of the loop. Adjust your indents so that the "return" statement is outside the "for" loop, but still inside your function. I exaggerated the indentations on your original code so that you can see it more clearly.
def encrypt(msg):
encrypted_msg = " "
for str in msg:
if str.isupper():
encrypted_msg += "!" + str.lower() + "!"
elif str.islower():
encrypted_msg += "!" + str.upper() + "!"
elif str.isdigit():
encrypted_msg += str(int(str) ** 3)
elif str.isspace():
encrypted_msg += "$"
else:
encrypted_msg += str
return encrypted_msg # no longer in the for loop, but still in the function definition
Rachel M.
WHen I do move it out of the for loop is gives me an error02/21/23