Given a one-dimensional array of numeric values, numbering N elements. To exclude from it M elements, starting from the number K.

N = 10 K = 5 M = 2 mas = range(N) print (mas) mas [K:K+M] = [] print (mas) 

Error: mas [K: K + M] = [] TypeError: 'range' object does not support item assignment

  • 2
    @Antonru better change the title. Headings like "urgently need help," "people help," etc. usually have the opposite effect - DreamChild

2 answers 2

 mas=list(range(N)) #!!!!! del(mas[K:K+M]) 

or

 mas [K:K+M]=[] 
     print (list(mas[:K]) + list(mas[K+M:])) 
    • Everything is exactly a mistake. On mas swears. If you declare in brackets. That mistake again - Antonru
    • @Antonru, it works for me, write what specific error (I suppose it swears on a print in brackets). - etki
    • one
      apparently the questioner has 3 pythons, and Fike has the second. - KoVadim
    • one
      @Antonru, took the liberty to edit the answer @LinnTroll, try. - etki
    • one
      Well or so:> N = 10> K = 5> M = 2> mas = list (range (10))> print (mas)> mas [K: K + M] = []> print (mas) - Alex Krass