Python Forum
Python Error List Index Out of Range
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python Error List Index Out of Range
#1
I am making a program using python and tkinter which basically is an expense tracking system. However, I am getting an error when running my program which has to do with the code shown below. It is raising an error, mentioning that the 'list index is out of range.'

It confuses me that I am getting this error because the for loop (in this case) runs only once and the index seems to be within range as the value of 'i' is 1 and the list that it is iterating through is as follows: [('admin', '999'), ('Cheese', 'incorrect')] Would anyone please be able to explain why I am getting this error...

        for i in range(1, len(self.l_credentials)):
            print(i)
            print(self.l_credentials)
            self.my_users.add_command(label="{}".format(self.l_credentials[i][0]), command=lambda: self.callback(self.l_credentials[i][0]))
            self.my_users.add_separator()
buran write Sep-03-2021, 05:18 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
Reply


Messages In This Thread
Python Error List Index Out of Range - by abhi1vaishnav - Sep-03-2021, 05:08 PM
RE: Python Error List Index Out of Range - by buran - Sep-03-2021, 05:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  pyscript index error while calling input from html form pyscript_dude 2 980 May-21-2023, 08:17 AM
Last Post: snippsat
  Index error help MRsquared 1 766 May-15-2023, 03:28 PM
Last Post: buran
Thumbs Down I hate "List index out of range" Melen 20 3,319 May-14-2023, 06:43 AM
Last Post: deanhystad
Exclamation IndexError: Replacement index 2 out of range for positional args tuple - help? MrKnd94 2 6,365 Oct-14-2022, 09:57 PM
Last Post: MrKnd94
  IndexError: list index out of range dolac 4 1,913 Jul-25-2022, 03:42 PM
Last Post: deanhystad
  I'm getting a String index out of range error debian77 7 2,349 Jun-26-2022, 09:50 AM
Last Post: deanhystad
  IndexError: list index out of range Anldra12 2 1,443 May-03-2022, 01:39 PM
Last Post: Anldra12
  TypeError: list indices must be integers or slices, not range Anldra12 2 2,581 Apr-22-2022, 10:56 AM
Last Post: Anldra12
  matplotlib x axis range goes over the set range Pedroski55 5 3,209 Nov-21-2021, 08:40 AM
Last Post: paul18fr
  IndexError: list index out of range rf_kartal 6 2,848 Sep-07-2021, 02:36 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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