I have made a list in python and I want to find an item in that list by an index number. However, I also have to use index numbers larger than the list. So for example:
list = [a, b, c, d]
for i in list:
number_that_i_want_returned = list.index(i) + int(5)
print(list[number_that_i_want_returned])
I'd like this to return the corresponding value in the list, and if the index number is larger than the remaining items in the list to start over at the beginning. However, this gives me a list index out of range. Is there any way I can make this work? Thanks in advance.
EDIT: This is my full program so far. I'm trying to create a ceasar cipher encrypter.
program_name = 'ceasar cipher\n'
print (program_name.upper())
org_line = input('enter the line to encrypt here: ')
decrypt_num = input('''by how many characters do you want to shift?
enter here: ''')
alphabet = ['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']
for char in org_line:
new_pos = alphabet.index(char) + int(decrypt_num)
print(alphabet[new_pos])
so now if I input for example 30 it says: list index out of range I'm new to python...