Welcome.

In this kata you are required to, given a string, replace every letter with its position in the alphabet.

If anything in the text isn't a letter, ignore it and don't return it.

`"a" = 1`, `"b" = 2`, etc.

## Example

```python
alphabet_position("The sunset sets at twelve o' clock.")
```
Should return `"20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11"` (as a string)

Source: codewars | Difficulty: EASY
Tags: String algorithms

Fundamentals

Starter code: def alphabet_position(text):
	

Solutions:
def alphabet_position(text):
	return ' '.join((str(ord(c) - 96) for c in text.lower() if c.isalpha()))


def alphabet_position(s):
	return ' '.join((str(ord(c) - ord('a') + 1) for c in s.lower() if c.isalpha()))


alphabet = 'abcdefghijklmnopqrstuvwxyz'

def alphabet_position(text):
	if type(text) == str:
		text = text.lower()
		result = ''
		for letter in text:
			if letter.isalpha() == True:
				result = result + ' ' + str(alphabet.index(letter) + 1)
		return result.lstrip(' ')


from string import ascii_lowercase

def alphabet_position(text):
	return ' '.join((str(ascii_lowercase.index(n.lower()) + 1) for n in text if n.isalpha()))


import string

def alphabet_position(text):
	return ' '.join([str(string.lowercase.index(letter.lower()) + 1) for letter in list(text) if letter.isalpha()])


def get_positions(text):
	for char in text:
		pos = ord(char)
		if pos >= 65 and pos <= 90:
			yield (pos - 64)
		if pos >= 97 and pos <= 122:
			yield (pos - 96)

def alphabet_position(text):
	return ' '.join((str(char) for char in get_positions(text)))


def alphabet_position(text):
	alphabet = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26}
	inds = []
	for x in text.lower():
		if x in alphabet:
			inds.append(alphabet[x])
	return ' '.join([str(x) for x in inds])


def alphabet_position(text):
	al = 'abcdefghijklmnopqrstuvwxyz'
	return ' '.join(filter(lambda a: a != '0', [str(al.find(c) + 1) for c in text.lower()]))


def alphabet_position(text):
	upper_alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	lower_alpha = 'abcdefghijklmnopqrstuvwxyz'
	l = []
	for i in text:
		if i in upper_alpha:
			index = upper_alpha.index(i) + 1
			l.append(str(index))
		elif i in lower_alpha:
			index = lower_alpha.index(i) + 1
			l.append(str(index))
	return ' '.join(l)


import string

def alphabet_position(text):
	lower_case_text = text.lower()
	alphabet = string.ascii_lowercase
	number = list(range(1, 27))
	dict_alphabet_number = dict(list(zip(alphabet, number)))
	collector = []
	for element in lower_case_text:
		if element in alphabet:
			collector.append(str(dict_alphabet_number[element]))
	return ' '.join(collector)