lst = [] try: lst[42] = 'Answer' # raises IndexError; list does not auto-expand except Exception as e: print(type(e)) print(e.args) print(e) lst = [None] * 8 # explicitly create a 8-element 'uninitialized' list lst[7] = True for i in range(len(lst)): v = lst[i] print('for in range():lst[' + str(i) + '] = ' + str(v)) [ print('[print() for ]:lst[' + str(i) + '] = ' + str(lst[i])) for i in range(len(lst)) ] print(lst)