Everyone knows passphrases. One can choose passphrases from poems, songs, movies names and so on but frequently
they can be guessed due to common cultural references.
You  can get your passphrases stronger by different means. One is the following:

choose a text in capital letters including or not digits and non alphabetic characters,
 
1. shift each letter by a given number but the transformed letter must be a letter (circular shift), 
2. replace each digit by its complement to 9, 
3. keep such as non alphabetic and non digit characters, 
4. downcase each letter in odd position, upcase each letter in even position (the first character is in position 0), 
5. reverse the whole result.

#Example:

your text: "BORN IN 2015!", shift 1

1 + 2 + 3 -> "CPSO JO 7984!"

4 "CpSo jO 7984!"

5 "!4897 Oj oSpC"

With longer passphrases it's better to have a small and easy program.
Would you write it?

https://en.wikipedia.org/wiki/Passphrase

Difficulty: EASY
Tags: String algorithms

Starter code:
def play_pass(s, n):
	

Solutions:
def play_pass(s, n):
	shiftText = ''
	for char in s:
		if char.isdigit():
			shiftText += str(9 - int(char))
		elif char.isalpha():
			shifted = ord(char.lower()) + n
			shiftText += chr(shifted) if shifted <= ord('z') else chr(shifted - 26)
		else:
			shiftText += char
	caseText = ''
	for i in range(len(shiftText)):
		caseText += shiftText[i].upper() if i % 2 == 0 else shiftText[i].lower()
	return caseText[::-1]


def play_pass(s, n):
	slower = s.lower()
	change = ''
	alphabet = 'abcdefghijklmnopqrstuvwxyz'
	for (i, char) in list(enumerate(slower)):
		if char in alphabet:
			ind = alphabet.index(char) + n
			if ind >= 26:
				ind = ind % 26
			if i % 2 == 0:
				change += alphabet[ind].upper()
			else:
				change += alphabet[ind].lower()
		elif char.isdigit():
			change += str(9 - int(char))
		else:
			change += char
	return change[::-1]


def play_pass(s, n):
	passphrase = list(s)
	for i in range(0, len(s)):
		if passphrase[i].isalpha():
			ascii = ord(passphrase[i].lower())
			passphrase[i] = chr(ascii + n - 26) if ascii + n > 122 else chr(ascii + n)
			passphrase[i] = passphrase[i].lower() if i % 2 == 1 else passphrase[i].upper()
		if passphrase[i].isdigit():
			passphrase[i] = str(9 - int(passphrase[i]))
	return ''.join(passphrase[::-1])


from string import digits, ascii_uppercase as auc

def play_pass(s, n):
	return ''.join((a.lower() if c % 2 else a for (c, a) in enumerate(s.translate(str.maketrans(auc + digits, auc[n:] + auc[:n] + digits[::-1])))))[::-1]


def play_pass(s, n):
	return ''.join([c.lower() if i % 2 != 0 else c for (i, c) in enumerate([chr((ord(c) - 65 + n) % 26 + 65) if ord(c) in range(65, 91) else str(abs(int(c) - 9)) if ord(c) in range(48, 58) else c for c in s])][::-1])


def play_pass(phrase, n):
	output = ''
	for (i, char) in enumerate(phrase):
		if char.isdigit():
			char = str(9 - int(char))
		elif char.isalpha():
			code = (ord(char) - 65 + n) % 26
			char = chr(code + 65)
		if i & 1:
			char = char.lower()
		output = char + output
	return output


from string import ascii_uppercase as letters, digits

def play_pass(s, n):
	return ''.join((c.lower() if i & 1 else c for (i, c) in enumerate(s.upper().translate(str.maketrans(letters + digits, letters[n:] + letters[:n] + digits[::-1])))))[::-1]


from string import ascii_lowercase as s

def play_pass(message, key):
	m = message.lower().translate(str.maketrans(s + '0123456789', s[key % 26:] + s[:key % 26] + '9876543210'))
	return ''.join([j if i % 2 == 1 else j.upper() for (i, j) in enumerate(m)][::-1])


from collections import deque

def play_pass(s, n):
	d = deque((chr(ord('A') + x) for x in range(26)))
	d.rotate(-n)
	return ''.join((d[ord(c) - ord('A')].lower() if c.isalpha() and i % 2 else d[ord(c) - ord('A')] if c.isalpha() else str(9 - int(c)) if c.isdigit() else c for (i, c) in enumerate(s)))[::-1]