How to access all elements of a list (composed of dictionaries)? [closed] The Next CEO of Stack OverflowHow to merge two dictionaries in a single expression?How do I check if a list is empty?How do I sort a list of dictionaries by a value of the dictionary?How do I sort a dictionary by value?Getting the last element of a list in PythonHow to make a flat list out of list of lists?How do I get the number of elements in a list in Python?How do I concatenate two lists in Python?How to clone or copy a list?How do I list all files of a directory?

What steps are necessary to read a Modern SSD in Medieval Europe?

How to compactly explain secondary and tertiary characters without resorting to stereotypes?

My ex-girlfriend uses my Apple ID to login to her iPad, do I have to give her my Apple ID password to reset it?

MT "will strike" & LXX "will watch carefully" (Gen 3:15)?

How seriously should I take size and weight limits of hand luggage?

Incomplete cube

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

Is it OK to decorate a log book cover?

Upgrading From a 9 Speed Sora Derailleur?

Free fall ellipse or parabola?

What did the word "leisure" mean in late 18th Century usage?

Small nick on power cord from an electric alarm clock, and copper wiring exposed but intact

Compensation for working overtime on Saturdays

Find the majority element, which appears more than half the time

Why was Sir Cadogan fired?

Which acid/base does a strong base/acid react when added to a buffer solution?

Strange use of "whether ... than ..." in official text

Is it possible to create a QR code using text?

Identify and count spells (Distinctive events within each group)

How can a day be of 24 hours?

Why do we say “un seul M” and not “une seule M” even though M is a “consonne”?

Is the 21st century's idea of "freedom of speech" based on precedent?

Is a linearly independent set whose span is dense a Schauder basis?

How dangerous is XSS



How to access all elements of a list (composed of dictionaries)? [closed]



The Next CEO of Stack OverflowHow to merge two dictionaries in a single expression?How do I check if a list is empty?How do I sort a list of dictionaries by a value of the dictionary?How do I sort a dictionary by value?Getting the last element of a list in PythonHow to make a flat list out of list of lists?How do I get the number of elements in a list in Python?How do I concatenate two lists in Python?How to clone or copy a list?How do I list all files of a directory?










0















I have two variables that are lists composed of dictionaries; a and b which will always have same number of elements.



For 3d graphing I create another dictionary from them. When I know the amount of elements this code words fine; say example I know there are 3.



fig = dict( data=[a[0],a[1],a[2],b[0],b[1],b[2]], layout=layout )


The problem is I in general will not know how many elements are in a and b. I cannot seem to figure out how to correctly iterate or loop through to replicate the code above in the general case.



The goal is to replicate the code above for the general case where I do not know the number of elements in a and b.



Any help is appreciated.










share|improve this question















closed as off-topic by roganjosh, js1568, Deadpool, Garrett Hyde, Al Foиce ѫ Mar 7 at 21:43


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – roganjosh, js1568, Deadpool, Garrett Hyde, Al Foиce ѫ
If this question can be reworded to fit the rules in the help center, please edit the question.




















    0















    I have two variables that are lists composed of dictionaries; a and b which will always have same number of elements.



    For 3d graphing I create another dictionary from them. When I know the amount of elements this code words fine; say example I know there are 3.



    fig = dict( data=[a[0],a[1],a[2],b[0],b[1],b[2]], layout=layout )


    The problem is I in general will not know how many elements are in a and b. I cannot seem to figure out how to correctly iterate or loop through to replicate the code above in the general case.



    The goal is to replicate the code above for the general case where I do not know the number of elements in a and b.



    Any help is appreciated.










    share|improve this question















    closed as off-topic by roganjosh, js1568, Deadpool, Garrett Hyde, Al Foиce ѫ Mar 7 at 21:43


    This question appears to be off-topic. The users who voted to close gave this specific reason:


    • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – roganjosh, js1568, Deadpool, Garrett Hyde, Al Foиce ѫ
    If this question can be reworded to fit the rules in the help center, please edit the question.


















      0












      0








      0








      I have two variables that are lists composed of dictionaries; a and b which will always have same number of elements.



      For 3d graphing I create another dictionary from them. When I know the amount of elements this code words fine; say example I know there are 3.



      fig = dict( data=[a[0],a[1],a[2],b[0],b[1],b[2]], layout=layout )


      The problem is I in general will not know how many elements are in a and b. I cannot seem to figure out how to correctly iterate or loop through to replicate the code above in the general case.



      The goal is to replicate the code above for the general case where I do not know the number of elements in a and b.



      Any help is appreciated.










      share|improve this question
















      I have two variables that are lists composed of dictionaries; a and b which will always have same number of elements.



      For 3d graphing I create another dictionary from them. When I know the amount of elements this code words fine; say example I know there are 3.



      fig = dict( data=[a[0],a[1],a[2],b[0],b[1],b[2]], layout=layout )


      The problem is I in general will not know how many elements are in a and b. I cannot seem to figure out how to correctly iterate or loop through to replicate the code above in the general case.



      The goal is to replicate the code above for the general case where I do not know the number of elements in a and b.



      Any help is appreciated.







      python python-2.7 jupyter-notebook plotly






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 7 at 19:57









      glibdud

      5,69921731




      5,69921731










      asked Mar 7 at 19:53









      JB5JB5

      155




      155




      closed as off-topic by roganjosh, js1568, Deadpool, Garrett Hyde, Al Foиce ѫ Mar 7 at 21:43


      This question appears to be off-topic. The users who voted to close gave this specific reason:


      • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – roganjosh, js1568, Deadpool, Garrett Hyde, Al Foиce ѫ
      If this question can be reworded to fit the rules in the help center, please edit the question.







      closed as off-topic by roganjosh, js1568, Deadpool, Garrett Hyde, Al Foиce ѫ Mar 7 at 21:43


      This question appears to be off-topic. The users who voted to close gave this specific reason:


      • "Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: How to create a Minimal, Complete, and Verifiable example." – roganjosh, js1568, Deadpool, Garrett Hyde, Al Foиce ѫ
      If this question can be reworded to fit the rules in the help center, please edit the question.






















          3 Answers
          3






          active

          oldest

          votes


















          0














          This should do the job:



          fig = dict(data=a + b, layout=layout)


          The + operator will concatenate the operands when used between two lists.



          For example:



          >>> a = [1, 2, 3]
          >>> b = [4, 5, 6]
          >>> a + b
          [1, 2, 3, 4, 5, 6]





          share|improve this answer
































            0














            this should work:



            fig = dict( data=a + b, layout=layout )





            share|improve this answer
































              0














              You can chain both lists. It is more time efficient than creating of a new list by concatenating:



              from itertools import chain

              a = [1, 2, 3]
              b = [4, 5, 6]

              for i in chain(a, b):
              print(i)


              Output:



              1
              2
              3
              4
              5
              6





              share|improve this answer





























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                0














                This should do the job:



                fig = dict(data=a + b, layout=layout)


                The + operator will concatenate the operands when used between two lists.



                For example:



                >>> a = [1, 2, 3]
                >>> b = [4, 5, 6]
                >>> a + b
                [1, 2, 3, 4, 5, 6]





                share|improve this answer





























                  0














                  This should do the job:



                  fig = dict(data=a + b, layout=layout)


                  The + operator will concatenate the operands when used between two lists.



                  For example:



                  >>> a = [1, 2, 3]
                  >>> b = [4, 5, 6]
                  >>> a + b
                  [1, 2, 3, 4, 5, 6]





                  share|improve this answer



























                    0












                    0








                    0







                    This should do the job:



                    fig = dict(data=a + b, layout=layout)


                    The + operator will concatenate the operands when used between two lists.



                    For example:



                    >>> a = [1, 2, 3]
                    >>> b = [4, 5, 6]
                    >>> a + b
                    [1, 2, 3, 4, 5, 6]





                    share|improve this answer















                    This should do the job:



                    fig = dict(data=a + b, layout=layout)


                    The + operator will concatenate the operands when used between two lists.



                    For example:



                    >>> a = [1, 2, 3]
                    >>> b = [4, 5, 6]
                    >>> a + b
                    [1, 2, 3, 4, 5, 6]






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited Mar 7 at 20:03

























                    answered Mar 7 at 19:59









                    ruoholaruohola

                    1,447319




                    1,447319























                        0














                        this should work:



                        fig = dict( data=a + b, layout=layout )





                        share|improve this answer





























                          0














                          this should work:



                          fig = dict( data=a + b, layout=layout )





                          share|improve this answer



























                            0












                            0








                            0







                            this should work:



                            fig = dict( data=a + b, layout=layout )





                            share|improve this answer















                            this should work:



                            fig = dict( data=a + b, layout=layout )






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Mar 7 at 20:04

























                            answered Mar 7 at 19:58









                            MuditsMudits

                            70611028




                            70611028





















                                0














                                You can chain both lists. It is more time efficient than creating of a new list by concatenating:



                                from itertools import chain

                                a = [1, 2, 3]
                                b = [4, 5, 6]

                                for i in chain(a, b):
                                print(i)


                                Output:



                                1
                                2
                                3
                                4
                                5
                                6





                                share|improve this answer



























                                  0














                                  You can chain both lists. It is more time efficient than creating of a new list by concatenating:



                                  from itertools import chain

                                  a = [1, 2, 3]
                                  b = [4, 5, 6]

                                  for i in chain(a, b):
                                  print(i)


                                  Output:



                                  1
                                  2
                                  3
                                  4
                                  5
                                  6





                                  share|improve this answer

























                                    0












                                    0








                                    0







                                    You can chain both lists. It is more time efficient than creating of a new list by concatenating:



                                    from itertools import chain

                                    a = [1, 2, 3]
                                    b = [4, 5, 6]

                                    for i in chain(a, b):
                                    print(i)


                                    Output:



                                    1
                                    2
                                    3
                                    4
                                    5
                                    6





                                    share|improve this answer













                                    You can chain both lists. It is more time efficient than creating of a new list by concatenating:



                                    from itertools import chain

                                    a = [1, 2, 3]
                                    b = [4, 5, 6]

                                    for i in chain(a, b):
                                    print(i)


                                    Output:



                                    1
                                    2
                                    3
                                    4
                                    5
                                    6






                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Mar 7 at 21:24









                                    Mykola ZotkoMykola Zotko

                                    1,895518




                                    1,895518













                                        Popular posts from this blog

                                        Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                                        Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                                        Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved