Move every letter in the provided string forward 10 letters through the alphabet.

If it goes past 'z', start again at 'a'.

Input will be a string with length > 0.

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures

Starter code: def move_ten(st):
	

Solutions:
from string import ascii_lowercase as al
tbl = str.maketrans(al, al[10:] + al[:10])

def move_ten(st):
	return st.translate(tbl)


def move_ten(st):
	return ''.join((chr(ord(i) + 10) if i < 'q' else chr(ord(i) - 16) for i in st))


def move_ten(stg):
	return ''.join((chr(97 + (ord(c) - 87) % 26) for c in stg))


def move_ten(s):
	return ''.join((chr(97 + (ord(x) - 97 + 10) % 26) for x in s))


A = 'abcdefghijklmnopqrstuvwxyz'

def move_ten(s):
	return ''.join(s.translate(str.maketrans(A, A[10:] + A[:10])))


move_ten = lambda s: ''.join((chr((ord(e) - 87) % 26 + 97) for e in s))


def move_ten(st):
	a = 'abcdefghijklmnopqrstuvwxyzabcdefghij'
	return ''.join([a[a.find(i) + 10] for i in st])


move_ten = lambda s, t=str.maketrans('abcdefghijklmnopqrstuvwxyz', 'klmnopqrstuvwxyzabcdefghij'): s.translate(t)


a = 'abcdefghijklmnopqrstuvwxyz'

def move_ten(st):
	return ''.join((a[(a.find(x) + 10) % 26] for x in st))


def move_ten(st):
	alphabet = 'abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz'
	output = ''
	for letter in st:
		index = alphabet.index(letter)
		letter = alphabet[index + 10]
		output += letter
	return output