code = input("Voer een streepjescode in:")
code = int(code)
lijst = [int(i) for i in str(code)]
N1 = lijst[0]
N2 = lijst[1]
N3 = lijst[2]
N4 = lijst[3]
N5 = lijst[4]
N6 = lijst[5]
N7 = lijst[6]
N8 = lijst[7]
N9 = lijst[8]
N10 = lijst[9]
N11 = lijst[10]
N12 = lijst[11]
N13 = lijst[12]
N14 = lijst[13]
N15 = lijst[14]
N16 = lijst[15]
N17 = lijst[16]
N18 = lijst[17]
print(N18)
So this is the code I have at the moment. I looked on google for a way to make the N1 to N18 variables using a loop (or at least something that does not take so much space), but I could not find anything. Is there a way to make this code look overal nicer and make it more uncluttered? I want that for example N16 has as value the 16th digit in the list of 'code' all the way to 18. The code I am working on does not go further than 18.
I tried using the following code:
for i in range(0, 18):
globals()['N%s' % i] = lijst[i]
But it just gave me this IndexError: IndexError: list index out of range