+ 4

How do i do this?

def abstash_cipher(plaintext): Ex) abstash_cipher(“abcd”) should be ‘zxyw’ its in python Got to use a loop cannot use reverse

3rd Mar 2019, 2:19 AM
신지훈
신지훈 - avatar
2 Antworten
+ 10
The first thing which comes to mind is using list operations. def abstash_cipher(plaintext): return ''.join([chr(ord(x)+25-((ord(x)-97)*2)) for x in list(plaintext.lower())]) print(abstash_cipher("abcdefghijk")) This doesn't involve loops, but should give you a good idea of what to use, e.g. ord(), chr(), and the underlying conversion logic. Ofc, if you want to simplify the equation, you can use: return ''.join([chr(-ord(x)+219) for x in list(plaintext.lower())]) which is equivalent to the above.
3rd Mar 2019, 2:52 AM
Hatsy Rei
Hatsy Rei - avatar
+ 4
This is in Java, but the method shiftAlphabet can help: https://code.sololearn.com/cA316qa8j600/?ref=app
3rd Mar 2019, 2:55 AM
Paolo De Nictolis
Paolo De Nictolis - avatar