This question already has an answer here:


Given a string with any characters a-z or A-Z, return an 'encrypted' string, where all characters are replaced by the character next to it (assuming a QWERTY keyboard).

  • Case (uppercase, lowercase) does not matter.
  • The input will only have characters a-z and A-Z.

Shortest code in bytes wins.

Example Input and Output

Foo Foo Bar Bar PythonGpp Gpp Nst Nst [uyjpm

Case does not mattervSDR fprd mpy ,sYYrT


marked as duplicate by NoOneIsHere, Sriotchilism O'Zaic, Mego code-golf Mar 19 '17 at 4:32

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ Seems like a subset of this challenge. \$\endgroup\$ – Jonathan Allan Mar 19 '17 at 2:47
  • \$\begingroup\$ Looks fairly nice to me. have a +1 :) \$\endgroup\$ – Matthew Roh Mar 19 '17 at 3:06
  • \$\begingroup\$ Well at least Jelly would be non-competing there \$\endgroup\$ – Jonathan Allan Mar 19 '17 at 3:09
  • \$\begingroup\$ "The input will only have characters a-z and A-Z.": should this also say "and ` `" \$\endgroup\$ – micsthepick Mar 19 '17 at 3:33
  • \$\begingroup\$ Looks like it's more of a dupe of this \$\endgroup\$ – Okx Mar 19 '17 at 13:53

Jelly, 16 bytes


Try it online!


ŒlµØqż“[;,”Fṡ2Zy - Main link: string
Œl               - convert to lowercase
  µ              - monadic chain separation
   Øq            - qwerty yield: ["qwertyuiop","asdfghjkl","zxcvbnm"]
      “[;,”      - "[;,"
     ż           - zip: [["qwertyuiop","["],["asdfghjkl",";"],["zxcvbnm",","]
           F     - flatten: "qwertyuiop[asdfghjkl;zxcvbnm,"
            ṡ2   - overlapping pairs: ["qw","we","er","rt","ty","yu","ui","io","op","p[","[a","as","sd","df","fg","gh","hj","jk","kl","l;",";z","zx","xc","cv","vb","bn","nm","m,"]
              Z  - transpose: ["qwertyuiop[asdfghjkl;zxcvbnm","wertyuiop[asdfghjkl;zxcvbnm,"]
               y - translate the lowercased string with that mapping

Python 3, 91 bytes:

s='qwertyuiop[asdfghjkl;zxcvbnm,  ' 
print(''.join(s[s.index(c)+1]for c in input().lower()))
  • \$\begingroup\$ Can remove two bytes if there is no space in input... \$\endgroup\$ – micsthepick Mar 19 '17 at 3:30

Not the answer you're looking for? Browse other questions tagged or ask your own question.