## Python 3, <s>147</s> <s>179</s> 151 Bytes This method doesn't work for test cases containing ABCDEF due to the "g-97" statement.<s> x=[ord(i) for i in input()];c=chr print("".join([c(g)*(not(c(g).isalpha())) or(c(x[g-97])*(g>97)or c(x[g-65]-32))for g in[ord(i)for i in input()]])) </s> There must be a shorter way to do this using mapping, but I haven' quite figured the mapping function out yet. Golf'ed down from an original 180 just a shame its not quite a one liner. x=[ord(i)for i in input()];y=[ord(i) for i in input()];t="" for i in range(len(y)): g=y[i] if 122>g>97:t+=chr(x[g-97]) else:t+=chr(g)*(not(90>g>65))or chr(x[g-65]-32) print(t) New method gets it to work with fewer bytes: x=[ord(i)for i in input()];c=chr print("".join([(c(x[g-97])if 123>g>96 else c(x[g-65]-32))if c(g).isalpha()else c(g)for g in[ord(i)for i in input()]])) Movatica has a shorter [solution](https://codegolf.stackexchange.com/a/235702/55243) using the string library. And using := I could reduced my answer to a one-liner at the expense of a few bytes