Okay, so I've been working on a program that converts ascii values to text. The way that I have the code is functional, yet not convenient. Let me post the code and then explain.-
letters=[' enter ','',' ',0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N',\
'O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e',\
'f','g','h','i','j','k','l','m','n','o','p','q',\
'r','s','t','u','v','w','x','y','z']
numbers=[10,13,32,48,49,50,51,52,53,54,55,56,57,65,66,67,\
68,69,70,71,72,73,74,75,76,77,78,79,80,81,\
82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,\
106,107,108,109,110,111,112,113,114,115,116,\
117,118,119,120,121,122]
# Ascii values in the following list
result3=[83, 97, 109, 117, 101, 108, 32, 83, 109, 105, 116, 104, 13,\
10, 13, 10, 84, 104, 97, 110, 107, 32, 121, 111, 117, 32, 102, 111, 114, 32,\
108, 111, 111, 107, 105, 110, 103, 32, 116, 104, 101, 32, 111, 116, 104, 101, 114,\
32, 119, 97, 121, 32, 111, 110, 32, 116, 104, 101, 32, 105, 110, 99, 114, 101, 97, 115,\
101, 100, 32, 108, 101, 118, 101, 108, 115, 32, 111, 102, 32, 116, 111, 120, 105, 99, 32,\
99, 104, 101, 109, 105, 99, 97, 108, 115, 32, 105, 110, 32, 116, 104, 101, 32, 114, 105, 118,\
101, 114, 32, 114, 117, 110, 110, 105, 110, 103, 32, 97, 108, 111, 110, 103, 115, 105]
result4=[]
while len(result3)!=0: #while 3 is not equal to 0:
if result3[0]==numbers[0]:
print letters[0],
result4.append(letters[0])
result3.remove(result3[0])
letters=[' enter ','',' ',0,1,2,3,4,5,6,7,8,9,'A','B','C','D','E','F','G','H','I','J','K','L','M','N',\
'O','P','Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f','g',\
'h','i','j','k','l','m','n','o','p','q',\
'r','s','t','u','v','w','x','y','z']
numbers=[10,13,32,48,49,50,51,52,53,54,55,56,57,\
65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,\
82,83,84,85,86,87,88,89,90,97,98,99,100,101,102,103,104,105,\
106,107,108,109,110,111,112,113,114,115,116,\
117,118,119,120,121,122]
elif result3[0]!=numbers[0]:
numbers.remove(numbers[0])
#print "letters 0", letters[0]
letters.remove(letters[0])
Okay, the indentation isn't quite correct in this posted code here, but what this does is it starts out with a list of possible ascii values in the numbers list and a list of equivalent text values in the letters list. Then it checks the result3 list and if the value in the result3 list doesn't match the first value in the numbers list, then it removes the first value in the numbers list until it is a match, then it prints that value and replaces the numbers list and the letters list. What I want to be able to do is specify the values for the letters and numbers at the beginning, then when I want to replace the values within the while loop, I want to refer back to the previous values without having to list all of them out again as it is currently in this code. I hope this makes sense.
Can anybody help me out with this. I've tried many different things, but none of them seem to work. And I'm guessing this is pretty sloppy code. Maybe somebody with a little more experience could tidy it up for me?
Any help is appreciated. Let me know if you need more clarification.