0

Okay, here's my issue. I want to take a message a user enters, and then take it and convert it to a number, the standard a-z = 1-26, with space equaling 0. I haven't put in any punctuation yet. Anyways, I think I needed a loop, and I made this code to do it:

```
message = raw_input()
x = 0
y = 0
letters = list(message)
letters_len = len(letters)
message_number = []
while x < letters_len:
if letters[x] == ' ':
y = 0
message_number.append(y)
x = x+1
if letters[x] == 'A' or 'a':
y = 1
message_number.append(y)
x = x+1
if letters[x] == 'B' or 'b':
y = 2
message_number.append(y)
x = x+1
if letters[x] == 'C' or 'c':
y = 3
message_number.append(y)
x = x+1
if letters[x] == 'D' or 'd':
y = 4
message_number.append(y)
x = x+1
if letters[x] == 'E' or 'e':
y = 5
message_number.append(y)
x = x+1
if letters[x] == 'F' or 'f':
y = 6
message_number.append(y)
x = x+1
if letters[x] == 'G' or 'g':
y = 7
message_number.append(y)
x = x+1
if letters[x] == 'H' or 'h':
y = 8
message_number.append(y)
x = x+1
if letters[x] == 'I' or 'i':
y = 9
message_number.append(y)
x = x+1
if letters[x] == 'J' or 'j':
y = 10
message_number.append(y)
x = x+1
if letters[x] == 'K' or 'k':
y = 11
message_number.append(y)
x = x+1
if letters[x] == 'L' or 'l':
y = 12
message_number.append(y)
x = x+1
if letters[x] == 'M' or 'm':
y = 13
message_number.append(y)
x = x+1
if letters[x] == 'N' or 'n':
y = 14
message_number.append(y)
x = x+1
if letters[x] == 'O' or 'o':
y = 15
message_number.append(y)
x = x+1
if letters[x] == 'P' or 'p':
y = 16
message_number.append(y)
x = x+1
if letters[x] == 'Q' or 'q':
y = 17
message_number.append(y)
x = x+1
if letters[x] == 'R' or 'r':
y = 18
message_number.append(y)
x = x+1
if letters[x] == 'S' or 's':
y = 19
message_number.append(y)
x = x+1
if letters[x] == 'T' or 'T':
y = 20
message_number.append(y)
x = x+1
if letters[x] == 'U' or 'u':
y = 21
message_number.append(y)
x = x+1
if letters[x] == 'V' or 'v':
y = 22
message_number.append(y)
x = x+1
if letters[x] == 'W' or 'w':
y = 23
message_number.append(y)
x = x+1
if letters[x] == 'X' or 'X':
y = 24
message_number.append(y)
x = x+1
if letters[x] == 'Y' or 'y':
y = 25
message_number.append(y)
x = x+1
if letters[x] == 'Z' or 'z':
y = 26
message_number.append(y)
x = x+1
```

Sorry the code is so long. Anyways, here's my issue. I'm using "Get help" as the example message. When I was just using the 'A' or 'a', and i typed print message_number, it came up with (1, 1, 1, 1, 1, 1, 1, 1). Including all letters, it gives an error, and if I print message_number, it shows (1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 6, 7, 8). Here's the error:

```
Traceback (most recent call last):
File "<pyshell#120>", line 38, in <module>
if letters[x] == 'I' or 'i':
IndexError: list index out of range
```

Can anyone help out?