Python Forum
List index out of range error while accessing 2 lists in python
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
List index out of range error while accessing 2 lists in python
#3
(Sep-29-2020, 05:08 AM)buran Wrote: list indexes are 0-based, so the max index is len(some_list)-1. That said - don't use for i in range(len(new_list)) to iterate over list. Look at https://python-forum.io/Thread-Basic-Nev...n-sequence

In addition - you do some weird stuff like variable = variable + "']" Can you provide sample data for both lists and expected output?

data list contents
Output:
RegInputOutput-ML Warning /sitework/soc/users/law/yeppy2/yeppy2chewy/yeppy2chewy_4ports/yeppy2/Spy_test_prj/mem/project_1/project_1.srcs/sources_1/ip/blk_mem_gen_0/synth/blk_mem_gen_0.vhd 315 10 Port 'clka' is not registered [Hierarchy: 'block_ram_top.blk_mem_inst_0'] RegInputOutput-ML Warning /sitework/soc/users/law/yeppy2/yeppy2chewy/yeppy2chewy_4ports/yeppy2/Spy_test_prj/mem/project_1/project_1.srcs/sources_1/ip/blk_mem_gen_0/synth/blk_mem_gen_0.vhd 315 10 Port 'clka' is not registered [Hierarchy: 'block_ram_top.blk_mem_inst_1'] RegInputOutput-ML Warning /sitework/soc/users/law/yeppy2/yeppy2chewy/yeppy2chewy_4ports/yeppy2/Spy_test_prj/mem/project_1/project_1.srcs/sources_1/ip/blk_mem_gen_0/synth/blk_mem_gen_0.vhd 317 10 Port 'ena' is not registered [Hierarchy: 'block_ram_top.latch'] RegInputOutput-ML Warning /sitework/soc/users/law/yeppy2/yeppy2chewy/yeppy2chewy_4ports/yeppy2/Spy_test_prj/mem/project_1/project_1.srcs/sources_1/ip/blk_mem_gen_0/synth/blk_mem_gen_0.vhd 317 10 Port 'ena' is not registered [Hierarchy: 'block_ram_top.ff1'] RegInputOutput-ML Warning /sitework/soc/users/law/yeppy2/yeppy2chewy/yeppy2chewy_4ports/yeppy2/Spy_test_prj/mem/project_1/project_1.srcs/sources_1/ip/blk_mem_gen_0/synth/blk_mem_gen_0.vhd 319 10 Port 'wen' is not registered [Hierarchy: 'block_ram_top']
new_list contents
Output:
| block_ram_top | (top) | 23 | 23 | 0 | 0 | 138 | 0 | 2 | 0 | 4 | | (block_ram_top) | (top) | 7 | 7 | 0 | 0 | 9 | 0 | 0 | 0 | 0 | | blk_mem_inst_0 | blk_mem_gen_0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | | (blk_mem_inst_0) | blk_mem_gen_0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 0 |
variables that i extract in my code
Output:
inst_blk_mem_gen'] gnbram.gnativebmg.native_blk_mem_gen'] valid.cstr'] ramloop[0].ram.r'] prim_noinit.ram'] blk_mem_inst_1'] U0'] block_ram_top'] blk_mem_inst_0'] complex_multiplier_inst']
Expected target_data list: This should have all the data list items having the variable that i extract from the new_list items
Output:
RegInputOutput-ML Warning /sitework/soc/users/law/yeppy2/yeppy2chewy/yeppy2chewy_4ports/yeppy2/Spy_test_prj/mem/project_1/project_1.srcs/sources_1/ip/blk_mem_gen_0/synth/blk_mem_gen_0.vhd 315 10 Port 'clka' is not registered [Hierarchy: 'block_ram_top.blk_mem_inst_0'] RegInputOutput-ML Warning /sitework/soc/users/law/yeppy2/yeppy2chewy/yeppy2chewy_4ports/yeppy2/Spy_test_prj/mem/project_1/project_1.srcs/sources_1/ip/blk_mem_gen_0/synth/blk_mem_gen_0.vhd 315 10 Port 'clka' is not registered [Hierarchy: 'block_ram_top.blk_mem_inst_1'] RegInputOutput-ML Warning /sitework/soc/users/law/yeppy2/yeppy2chewy/yeppy2chewy_4ports/yeppy2/Spy_test_prj/mem/project_1/project_1.srcs/sources_1/ip/blk_mem_gen_0/synth/blk_mem_gen_0.vhd 319 10 Port 'wen' is not registered [Hierarchy: 'block_ram_top']
Reply


Messages In This Thread
RE: List index out of range - by buran - Sep-29-2020, 05:08 AM
RE: List index out of range - by K11 - Sep-29-2020, 05:24 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  IndexError: list index out of range Laplace12 1 57 Yesterday, 10:47 AM
Last Post: Yoriz
  python error: bad character range \|-t at position 12 faustineaiden 0 168 May-28-2021, 09:38 AM
Last Post: faustineaiden
  How to resolve Index Error in my code? codify110 6 352 May-22-2021, 11:04 AM
Last Post: supuflounder
  List of lists - merge sublists with common elements medatib531 1 344 May-09-2021, 07:49 AM
Last Post: Gribouillis
  Sort List of Lists by Column Nju 1 364 Apr-13-2021, 11:59 PM
Last Post: bowlofred
  IndexError: list index out of range brunolelli 11 910 Mar-25-2021, 11:36 PM
Last Post: brunolelli
  index of range, but data prints out mrc06405j 1 339 Mar-25-2021, 07:20 PM
Last Post: buran
  Changing Index of 2 List in python giddyhead 0 314 Mar-05-2021, 05:45 PM
Last Post: giddyhead
  IndexError: list index out of range ramu4651 2 534 Jan-24-2021, 01:45 PM
Last Post: buran
  string index out of range jade_kim 4 476 Jan-13-2021, 05:41 AM
Last Post: jade_kim

Forum Jump:

User Panel Messages

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