omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Immutable, Immutable! Don’t need no stinkin’....

    Pythonista
    3
    3
    1836
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • adrius42
      adrius42 last edited by

      I have tried searching the manual for a simple action...

      I want to store variables in an array, I found and implemented many ways of doing this
      Creating the array
      variablesarray=[]
      Creating the first elements is easy with variablesarray.append(list)

      I can even read them back with variablesarray[x][y]

      But I cannot for the life of me figure out how to change an element in the array

      In my old basic world it was very simple variablesarray[x][y]=newvalue

      How can I achieve this simple variable change in Python, what am I missing.

      I am confident it will be something simple... but I have yet to discover it.

      Pointers gratefully received...

      mikael 1 Reply Last reply Reply Quote 0
      • JonB
        JonB last edited by

        a=[[1,2,3],[4,5,6],[7,8,9]]
        print(a)
        print('a[0]append')
        a[0].append(4)
        print(a)
        print('a[0].extend [0]')
        a[0].extend([5,6])
        print(a)
        print('a[0][0]=99')
        a[0][0]=99
        print(a)
        print('del(a[0][1])')
        del(a[0][1])
        print(a)
        print('a[0].insert(1,2)')
        a[0].insert(1,2)
        print(a)
        

        Are you getting an error of some sort? Maybe post the code that was failing. lists in python are generally mutable.

        1 Reply Last reply Reply Quote 1
        • mikael
          mikael @adrius42 last edited by

          @adrius42, just making sure you are not appending or overriding list, which is a built-in.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors