Aavatar Aavatar - 9 months ago 71
Python Question

Modifying I/O Data in Python

(Python 3.5) Is there a way to change an letter (from user input) into a different letter? This would work like an encryption program. The user would write, "Hello" and the program would print, "Gwkki."

H = "G"
e = "w"
l = "k"
o = "i"
q = input("Message: ")
print (q[0:4])


yes you can simply use str.translate like this

text = input('Enter your text: ')

_in = "helo"
out = "Gwki"

print(text.translate(text.maketrans(_in, out)))

just like the name says, it "translates"(substitutes) each letter from your text found in your text in _in to the corresponding value in out