+ 1
Secret message code coach
1. How can I make make this more efficient in python, typing every single letter in the alphabet felt pointless? 2. What’s a good start to doing this in Cpp or Java? https://code.sololearn.com/cUy2kOHsn1xI/?ref=app
2 Antworten
+ 1
# try a couple of comprehensions
'''
x=[chr(x) for x in range(97,123)]
y=[chr(x) for x in range(122,96,-1)]
ralph=dict(zip(x,y))
'''
+ 1
You can also try something like this:
words = input()
newstr = ""
for x in range(len(words)):
y=words[x]
ascii=ord(y)
if y.isupper(): newstr+=chr(abs(ascii-90)+65)
elif y.islower(): newstr+=chr(abs(ascii-122)+97)
elif words[x]==" ": newstr+=y
else: newstr+=y
print(newstr)