Python Forum
For loop index out of bounds
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
For loop index out of bounds
#2
A length 73 array has index values 0..72. 73 is out of range.

It should always draw suspicion when you loop "i" over the length of an array and use "i+1" as an array index.
for i in range(length2): 
    if kl_50_132_transposed.iat[i,2] != kl_50_132_transposed.iat[i-1,2]:
        end_date.append(kl_50_132_transposed.iat[i+1,3])
Reply


Messages In This Thread
For loop index out of bounds - by armitron121 - Feb-07-2022, 11:18 PM
RE: For loop index out of bounds - by deanhystad - Feb-08-2022, 04:29 AM
RE: For loop index out of bounds - by armitron121 - Feb-08-2022, 04:23 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  IndexError: index 10 is out of bounds for axis 0 with size 10 Mehboob 11 2,321 Sep-14-2023, 06:54 AM
Last Post: Mehboob
  Replace for loop to search index position illmattic 5 1,359 Sep-03-2022, 04:04 PM
Last Post: illmattic
  IndexError: index 10 is out of bounds for axis 0 with size 1 vahid89 1 12,355 Jan-07-2021, 06:19 PM
Last Post: deanhystad
  when this error rise?index 28 is out of bounds for axis 0 with size 13 abbaszandi 1 5,076 Nov-10-2020, 08:46 PM
Last Post: deanhystad
  String index out of bounds ( Python : Dict ) kommu 2 2,439 Jun-25-2020, 08:52 PM
Last Post: menator01
  IndexError: index 0 is out of bounds for axis 0 with size 0 error tmhsa 5 4,555 Apr-25-2020, 01:15 PM
Last Post: tmhsa
  IndexError: index 8 is out of bounds for axis 0 with size 8 Help_me_Please 6 66,646 Jan-03-2020, 01:51 PM
Last Post: Help_me_Please
  Get all values of for loop with an index BollerwagenIng 2 2,549 Aug-09-2019, 07:58 AM
Last Post: BollerwagenIng
  cannot import scipy.optimize.Bounds larkypython 2 7,329 May-05-2019, 04:09 AM
Last Post: larkypython
  Index error using pop in nested loop PerksPlus 3 3,435 Mar-28-2019, 03:11 PM
Last Post: ichabod801

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020