0

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)
7
  • 2
    Have you tried password += "q*s"? Commented Mar 15, 2021 at 22:29
  • 1
    After the for loop can't you just do password += "q*s" Commented Mar 15, 2021 at 22:29
  • I'm just wondering why there's like 3 identical answers all posted at different times. Commented Mar 15, 2021 at 22:37
  • 1
    More like 5 with the comments. Commented Mar 15, 2021 at 22:39
  • 1
    At least I can say mine was there first ;) Commented Mar 15, 2021 at 22:41

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

vote for this one as he was definitely the first ;-)
0

Try and add: password+='q*s' .After your for loop

Comments

0

after your for-loop, you can add:

password += 'q*s'

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.