So , I have this code snippet :
import sys
while True:
print("Make sure the number of digits are exactly 12 : ")
x = input()
if str(x) == 12:
break
code = []
for i in range(12):
code[i] = int(x[i])
I want the program to repeat the lines , "Make sure .... 12 :" if 12 digits are not inputed. After that , I am copying them to an array to access each individual element of it to do very basic arithmetic calculations . Am I going in the right direction ? I am totally new to python , how can I fix this ? The above code is showing the following error .
Traceback (most recent call last):
File "C:\Users\Arjo\Desktop\hw2a.py", line 14, in <module>
code[i] = int(x[i])
IndexError: list assignment index out of range