This is my task: https://i.stack.imgur.com/qv6us.png
I have tried to get each item out of the ASCII list by using z as the list item so the program increases z by one every time I go through the for loop.
ciphertext = []
z=0
for item in messagelist:                    # messagelist a list of characters
If there is a space then I want to ignore it.
    if ' ' in messagelist:
        break
Then I want it to add the item to an integer:'offsetfactor'.
    else:                                   # ascii list is a list of ascii codes/integers
    y = asciilist[z] + offsetFactor     # offset factor is a randomly generated integer
    print (y)
Then if the answer is more than 126, I will minus 94 and turn the answer into an ASCII character. Then I want to append all the ASCII characters to a list and convert the list into a string.
    if y > 126:
        y = y - 94
        asciichar = str(chr(y))         # turns y into an ascii character
        ciphertext.append(asciichar)    # adds the ascii character to a list called ciphertext
    else:
        asciichar = str(chr(y))        
        ciphertext.append(asciichar)
    z+=1
encrypted = str(ciphertext)                # turns ciphertext into a string
print ('Your encrypted message is: ',encrypted)
This doesn't seem to be working as 'encrypted' is printed as an empty list. I will be grateful for any help as it took me ages even to write the question!
