I understand it is possible for you my methods seem primitive, but Python began to study only 3-4 days ago.

a = int(input()) b = list(map(int, input().split())) q = c = int(input()) w = [] p = 0 while q > 0: d= list(map(int, input().split())) w.extend(d) q -= 1 print(w) while c > 0: print(a[w[p]:w[p+1]:]) #на этом месте выдает ошибку:'int' object is not subscriptable c -= 1 p += 2 
  • 2
    Because a is an integer. You probably wanted: print(b[w[p]:w[p+1]:]) , because b is a list and you will succeed) - S. Nick
  • Let us make meaningful variable names, making it much easier to find an error. For example, the variables cnt and list_cars. It is logical that cnt is an int variable, and the slice for it does not work. And list_ immediately hints that it is an iterable object. - ioprst
  • Thank you very much, caught up - Viskhan

1 answer 1

You have a variable - it refers to an int object, and in the line with an error you take a in some slice. In a slice, only iterable objects can be taken.

  • Thank you very much, caught up - Viskhan