Reputation: 11
I'm currently in a Python Scripting course and I'm struggling with a lab. This is the prompt: Many user-created passwords are simple and easy to guess. Write a program that takes a simple password and makes it stronger by replacing characters using the key below, and by appending "q*s" to the end of the input string.
i becomes ! a becomes @ m becomes M B becomes 8 o becomes .
Ex: If the input is: mypassword the output is: [email protected]*s
My Issue: I can't figure out how to add the "qs" at the end of the new password so instead of it being [email protected]*s, my code is running [email protected]
I've managed to get this:
word = input()
password = ''
for character in word:
if(character=='i'):
password += '!'
elif(character=='a'):
password += '@'
elif(character=='m'):
password += 'M'
elif(character=='B'):
password += '8'
elif(character=='o'):
password += '.'
else:
password += character
print(password)
Upvotes: 0
Views: 1889
Reputation: 148
Just before you print the password, add password += 'q*s'
, outside of the for loop.
This will add the q*s
after all other characters have been processed.
Upvotes: 1