Python Forum
2D Array/List OR using variables in other variable names?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
2D Array/List OR using variables in other variable names?
#1
I'm trying to do one of two things:
1- .append() to a 2d array.
OR
2- have multiple arrays, e.g. array1, array2, then use array+intvar.append()

I have tried defining my array (list) with array = [][] and array = [[]].
I have tried appending to array[1].append("test").

I have also tried:
array1 = []
intvar = 1
exec("array"+str(intvar)).append("test"))
Error: AttributeError: 'NoneType' object has no attribute 'append'

Ideally, solution 1 would be better than solution 2, because I don't need to manually create X arrays. However, I would like an explanation for both methods.

Thank you in advance.
Reply


Messages In This Thread
2D Array/List OR using variables in other variable names? - by IAMK - Apr-14-2018, 02:09 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Advancing Through Variables In A List knight2000 0 560 May-13-2023, 03:30 AM
Last Post: knight2000
  functional LEDs in an array or list? // RPi user Doczu 5 1,772 Aug-23-2022, 05:37 PM
Last Post: Yoriz
  Split string using variable found in a list japo85 2 1,385 Jul-11-2022, 08:52 AM
Last Post: japo85
  Create array of values from 2 variables paulo79 1 1,167 Apr-19-2022, 08:28 PM
Last Post: deanhystad
  Referencing string names in df to outside variables illmattic 1 1,421 Nov-16-2021, 12:47 PM
Last Post: jefsummers
Question Calling on a Variable using other Variables jacknewport 4 2,086 Jul-23-2021, 04:18 PM
Last Post: jacknewport
  An IF statement with a List variable dedesssse 3 8,615 Jul-08-2021, 05:58 PM
Last Post: perfringo
  Create variable and list dynamically quest_ 12 4,634 Jan-26-2021, 07:14 PM
Last Post: quest_
  LIST or ARRAY Comparison and change of value nio74maz 0 1,744 Dec-21-2020, 05:52 PM
Last Post: nio74maz
Question Matching variable to a list index Gilush 17 6,106 Nov-30-2020, 01:06 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

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