Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to work with list
#8
(Jan-23-2023, 04:21 PM)kafka_trial Wrote: why do I get the following message:

Error:
Traceback (most recent call last): File "C:/Users/mustafa.turus/OneDrive - Capital City College Group/Desktop/sirrrrr.py", line 24, in <module> total[i]=history[i]+maths[i] IndexError: list assignment index out of range
total = [] makes a list with no elements. total[0] indexes an element that doesn't exist, thus "index error".

Do not use reply unless referring to a previous post. Even then, edit the reply to only include the important parts. Here I only needed to reference the question and the error message, so I removed everything else from the reply. Think of what a mess it would be if I replied to your post, and you replied to mine, and I replied back to yours and the reply part of each post becomes huge, dwarfing the important additional content.
Reply


Messages In This Thread
How to work with list - by kafka_trial - Jan-12-2023, 11:24 AM
RE: How to work with list - by rob101 - Jan-12-2023, 03:22 PM
RE: How to work with list - by kafka_trial - Jan-16-2023, 11:39 AM
RE: How to work with list - by rob101 - Jan-17-2023, 05:25 PM
RE: How to work with list - by kafka_trial - Jan-23-2023, 04:21 PM
RE: How to work with list - by deanhystad - Jan-23-2023, 04:34 PM
RE: How to work with list - by deanhystad - Jan-12-2023, 05:12 PM
RE: How to work with list - by rob101 - Jan-23-2023, 04:31 PM
RE: How to work with list - by jefsummers - Jan-24-2023, 01:30 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Why do I have to repeat items in list slices in order to make this work? Pythonica 7 1,399 May-22-2023, 10:39 PM
Last Post: ICanIBB
  Beginner: Code not work when longer list raiviscoding 2 858 May-19-2023, 11:19 AM
Last Post: deanhystad
  how does .join work with list and dictionaries gr3yali3n 7 3,361 Jul-07-2020, 09:36 PM
Last Post: bowlofred
  A strange list, how does this work? Pedroski55 1 1,742 May-13-2020, 11:24 PM
Last Post: snippsat
Question Why does modifying a list in a for loop not seem to work? umut3806 2 2,329 Jul-22-2019, 08:25 PM
Last Post: umut3806
  Example of list comprehensions doesn't work Truman 17 10,961 May-20-2018, 05:54 AM
Last Post: buran
  List 3 dimensions reference does not work Mario793 1 2,669 Mar-02-2018, 12:35 AM
Last Post: ka06059
  Trying to figure out how list comprehensions work tozqo 4 4,058 Jul-11-2017, 01:26 PM
Last Post: ichabod801
  Why list(dict.keys()) does not work? landlord1984 5 13,725 Feb-02-2017, 05:52 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