I'm new to python and coding in general. Here is a problem from my homework, as well as my current code. I know that I only have one of the parts, but I wanted to figure this one out before moving on to the rest. With my loop, I can find and identify the letter i, but I can't figure out how to change the i's to 1's.
Problem:
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 "!" to the end of the input string.
i becomes 1 a becomes @ m becomes M B becomes 8 s becomes $Ex: If the input is:
mypasswordthe output is:
Myp@$$word!Hint: Python strings are immutable, but support string concatenation. Store and build the stronger password in the given password variable.
Code:
word = input()
password = ()
for letter in word:
if letter == 'i':
password = password+'1'
else: password = password+letter
print(password)
input: igigigig
output: igigigig
"". Also this should do