'int' object is not subscriptable

kol_elementi = int(input(""))
elements = []
for el in range(1, kol_elementi + 1):
    el1 = input("Write a element")
    elements.append(el1)
izbor = input("Make you choose")
if (izbor=="Wzemi"):
    n = input("Write the num of element")
    vzeto = kol_elementi[n]
    print(vzeto)
elif (izbor=="Wzemi bez"):
    n = input("Write the num whithout")
    vzeto = kol_elementi[n:]
    print(kol_elementi)

Type error: ‘int’ object is not subscriptable

What is a element to be “subscriptable”

Hi Daniel,

“Subscriptable” means an object supports subscription, meaning you can write object[index].

>>> l = [1,2,3]
>>> s = '123'
>>> i = 123
>>> l[0]
1
>>> s[0]
'1'
>>> i[0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'int' object is not subscriptable
>>>
1 Like