Should I Append or Join a list of dict and And how in python?How do I check if a list is empty?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow to append something to an array?Python join: why is it string.join(list) instead of list.join(string)?How 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 do I list all files of a directory?How do you append to a file in Python?

What are the advantages of simplicial model categories over non-simplicial ones?

What should you do if you miss a job interview (deliberately)?

How does a computer interpret real numbers?

Can disgust be a key component of horror?

Moving brute-force search to FPGA

What are some good ways to treat frozen vegetables such that they behave like fresh vegetables when stir frying them?

Can a College of Swords bard use a Blade Flourish option on an opportunity attack provoked by their own Dissonant Whispers spell?

On a tidally locked planet, would time be quantized?

Can the US President recognize Israel’s sovereignty over the Golan Heights for the USA or does that need an act of Congress?

Open a doc from terminal, but not by its name

Why does the Sun have different day lengths, but not the gas giants?

Non-trope happy ending?

A social experiment. What is the worst that can happen?

Strong empirical falsification of quantum mechanics based on vacuum energy density

Does IPv6 have similar concept of network mask?

What is going on with 'gets(stdin)' on the site coderbyte?

How can I write humor as character trait?

What should you do when eye contact makes your subordinate uncomfortable?

I'm the sea and the sun

Why does AES have exactly 10 rounds for a 128-bit key, 12 for 192 bits and 14 for a 256-bit key size?

Quoting Keynes in a lecture

Can I still be respawned if I die by falling off the map?

How to cover method return statement in Apex Class?

Are Captain Marvel's powers affected by Thanos' actions in Infinity War



Should I Append or Join a list of dict and And how in python?


How do I check if a list is empty?Finding the index of an item given a list containing it in PythonDifference between append vs. extend list methods in PythonHow to append something to an array?Python join: why is it string.join(list) instead of list.join(string)?How 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 do I list all files of a directory?How do you append to a file in Python?













-2















Using this code I was able to cycle through several instances of attributes and extract First and Last name if they matched the criteria. The results are a list of dict. How would i make all of these results which match the criteria, return as a full name each on it's own line as text?



my_snapshot = cfm.child('teamMap').get()
for players in my_snapshot:
if players['age'] != 27:
print(players['firstName'], players['lastName'])


Results of Print Statement



'Chandon', 'Sullivan'
'Urban', 'Brent'









share|improve this question




























    -2















    Using this code I was able to cycle through several instances of attributes and extract First and Last name if they matched the criteria. The results are a list of dict. How would i make all of these results which match the criteria, return as a full name each on it's own line as text?



    my_snapshot = cfm.child('teamMap').get()
    for players in my_snapshot:
    if players['age'] != 27:
    print(players['firstName'], players['lastName'])


    Results of Print Statement



    'Chandon', 'Sullivan'
    'Urban', 'Brent'









    share|improve this question


























      -2












      -2








      -2








      Using this code I was able to cycle through several instances of attributes and extract First and Last name if they matched the criteria. The results are a list of dict. How would i make all of these results which match the criteria, return as a full name each on it's own line as text?



      my_snapshot = cfm.child('teamMap').get()
      for players in my_snapshot:
      if players['age'] != 27:
      print(players['firstName'], players['lastName'])


      Results of Print Statement



      'Chandon', 'Sullivan'
      'Urban', 'Brent'









      share|improve this question
















      Using this code I was able to cycle through several instances of attributes and extract First and Last name if they matched the criteria. The results are a list of dict. How would i make all of these results which match the criteria, return as a full name each on it's own line as text?



      my_snapshot = cfm.child('teamMap').get()
      for players in my_snapshot:
      if players['age'] != 27:
      print(players['firstName'], players['lastName'])


      Results of Print Statement



      'Chandon', 'Sullivan'
      'Urban', 'Brent'






      python list dictionary join append






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 8 at 5:27







      Will James

















      asked Mar 8 at 2:37









      Will JamesWill James

      84




      84






















          2 Answers
          2






          active

          oldest

          votes


















          1














          Are you looking for this:



           print(players['firstName'], players['lastName'])



          This would output:



          Chandon Sullivan
          Urban Brent



          Your original trial just put the items to a set , and then printed the set, for no apparent reason.



           



          Edit:



          You can also for example join the firstName and lastName to be one string and then append the combos to a lists. Then you can do whatever you need with the list:



          names = []
          my_snapshot = cfm.child('teamMap').get()
          for players in my_snapshot:
          if players['age'] != 27:
          names.append(f"players['firstName'] players['lastName']")


          If you're using a version of Python lower than 3.6 and can't use f-strings you can do the last line for example like this:



          names.append(" ").format(players['firstName'], players['lastName'])


          Or if you prefer:



          names.append(players['firstName'] + ' ' + players['lastName'])





          share|improve this answer

























          • You are correct. It displays correctly in the console but when try to pass players['firstName'], players['lastName'] to a device it only shows the last found record. So I was trying to figure out how how I would join each record so that it could be sent to the device displaying all of the found records.

            – Will James
            Mar 8 at 4:11











          • @WillJames what do you mean by passing to a device?

            – ruohola
            Mar 8 at 10:00











          • @WillJames see my edit

            – ruohola
            Mar 8 at 12:07











          • thanks I figured it out last night and I put my solution below.

            – Will James
            Mar 8 at 17:12











          • @WillJames feel free to mark my answer as accepted if you feel that it provided a good solution :)

            – ruohola
            Mar 8 at 17:15


















          0














          Ok I figured out by appending the first and last name and creating a list for the found criteria. I then converted the list to a string to display it on the device.



           full_list = []

          my_snapshot = cfm.child('teamMap').get()
          for players in my_snapshot:
          if players['age'] != 27:
          full_list.append((players['firstName'] + " " + players['lastName']))

          send_message('n'.join(str(i) for i in full_list))





          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55055934%2fshould-i-append-or-join-a-list-of-dict-and-and-how-in-python%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            Are you looking for this:



             print(players['firstName'], players['lastName'])



            This would output:



            Chandon Sullivan
            Urban Brent



            Your original trial just put the items to a set , and then printed the set, for no apparent reason.



             



            Edit:



            You can also for example join the firstName and lastName to be one string and then append the combos to a lists. Then you can do whatever you need with the list:



            names = []
            my_snapshot = cfm.child('teamMap').get()
            for players in my_snapshot:
            if players['age'] != 27:
            names.append(f"players['firstName'] players['lastName']")


            If you're using a version of Python lower than 3.6 and can't use f-strings you can do the last line for example like this:



            names.append(" ").format(players['firstName'], players['lastName'])


            Or if you prefer:



            names.append(players['firstName'] + ' ' + players['lastName'])





            share|improve this answer

























            • You are correct. It displays correctly in the console but when try to pass players['firstName'], players['lastName'] to a device it only shows the last found record. So I was trying to figure out how how I would join each record so that it could be sent to the device displaying all of the found records.

              – Will James
              Mar 8 at 4:11











            • @WillJames what do you mean by passing to a device?

              – ruohola
              Mar 8 at 10:00











            • @WillJames see my edit

              – ruohola
              Mar 8 at 12:07











            • thanks I figured it out last night and I put my solution below.

              – Will James
              Mar 8 at 17:12











            • @WillJames feel free to mark my answer as accepted if you feel that it provided a good solution :)

              – ruohola
              Mar 8 at 17:15















            1














            Are you looking for this:



             print(players['firstName'], players['lastName'])



            This would output:



            Chandon Sullivan
            Urban Brent



            Your original trial just put the items to a set , and then printed the set, for no apparent reason.



             



            Edit:



            You can also for example join the firstName and lastName to be one string and then append the combos to a lists. Then you can do whatever you need with the list:



            names = []
            my_snapshot = cfm.child('teamMap').get()
            for players in my_snapshot:
            if players['age'] != 27:
            names.append(f"players['firstName'] players['lastName']")


            If you're using a version of Python lower than 3.6 and can't use f-strings you can do the last line for example like this:



            names.append(" ").format(players['firstName'], players['lastName'])


            Or if you prefer:



            names.append(players['firstName'] + ' ' + players['lastName'])





            share|improve this answer

























            • You are correct. It displays correctly in the console but when try to pass players['firstName'], players['lastName'] to a device it only shows the last found record. So I was trying to figure out how how I would join each record so that it could be sent to the device displaying all of the found records.

              – Will James
              Mar 8 at 4:11











            • @WillJames what do you mean by passing to a device?

              – ruohola
              Mar 8 at 10:00











            • @WillJames see my edit

              – ruohola
              Mar 8 at 12:07











            • thanks I figured it out last night and I put my solution below.

              – Will James
              Mar 8 at 17:12











            • @WillJames feel free to mark my answer as accepted if you feel that it provided a good solution :)

              – ruohola
              Mar 8 at 17:15













            1












            1








            1







            Are you looking for this:



             print(players['firstName'], players['lastName'])



            This would output:



            Chandon Sullivan
            Urban Brent



            Your original trial just put the items to a set , and then printed the set, for no apparent reason.



             



            Edit:



            You can also for example join the firstName and lastName to be one string and then append the combos to a lists. Then you can do whatever you need with the list:



            names = []
            my_snapshot = cfm.child('teamMap').get()
            for players in my_snapshot:
            if players['age'] != 27:
            names.append(f"players['firstName'] players['lastName']")


            If you're using a version of Python lower than 3.6 and can't use f-strings you can do the last line for example like this:



            names.append(" ").format(players['firstName'], players['lastName'])


            Or if you prefer:



            names.append(players['firstName'] + ' ' + players['lastName'])





            share|improve this answer















            Are you looking for this:



             print(players['firstName'], players['lastName'])



            This would output:



            Chandon Sullivan
            Urban Brent



            Your original trial just put the items to a set , and then printed the set, for no apparent reason.



             



            Edit:



            You can also for example join the firstName and lastName to be one string and then append the combos to a lists. Then you can do whatever you need with the list:



            names = []
            my_snapshot = cfm.child('teamMap').get()
            for players in my_snapshot:
            if players['age'] != 27:
            names.append(f"players['firstName'] players['lastName']")


            If you're using a version of Python lower than 3.6 and can't use f-strings you can do the last line for example like this:



            names.append(" ").format(players['firstName'], players['lastName'])


            Or if you prefer:



            names.append(players['firstName'] + ' ' + players['lastName'])






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Mar 8 at 12:13

























            answered Mar 8 at 2:40









            ruoholaruohola

            1,428319




            1,428319












            • You are correct. It displays correctly in the console but when try to pass players['firstName'], players['lastName'] to a device it only shows the last found record. So I was trying to figure out how how I would join each record so that it could be sent to the device displaying all of the found records.

              – Will James
              Mar 8 at 4:11











            • @WillJames what do you mean by passing to a device?

              – ruohola
              Mar 8 at 10:00











            • @WillJames see my edit

              – ruohola
              Mar 8 at 12:07











            • thanks I figured it out last night and I put my solution below.

              – Will James
              Mar 8 at 17:12











            • @WillJames feel free to mark my answer as accepted if you feel that it provided a good solution :)

              – ruohola
              Mar 8 at 17:15

















            • You are correct. It displays correctly in the console but when try to pass players['firstName'], players['lastName'] to a device it only shows the last found record. So I was trying to figure out how how I would join each record so that it could be sent to the device displaying all of the found records.

              – Will James
              Mar 8 at 4:11











            • @WillJames what do you mean by passing to a device?

              – ruohola
              Mar 8 at 10:00











            • @WillJames see my edit

              – ruohola
              Mar 8 at 12:07











            • thanks I figured it out last night and I put my solution below.

              – Will James
              Mar 8 at 17:12











            • @WillJames feel free to mark my answer as accepted if you feel that it provided a good solution :)

              – ruohola
              Mar 8 at 17:15
















            You are correct. It displays correctly in the console but when try to pass players['firstName'], players['lastName'] to a device it only shows the last found record. So I was trying to figure out how how I would join each record so that it could be sent to the device displaying all of the found records.

            – Will James
            Mar 8 at 4:11





            You are correct. It displays correctly in the console but when try to pass players['firstName'], players['lastName'] to a device it only shows the last found record. So I was trying to figure out how how I would join each record so that it could be sent to the device displaying all of the found records.

            – Will James
            Mar 8 at 4:11













            @WillJames what do you mean by passing to a device?

            – ruohola
            Mar 8 at 10:00





            @WillJames what do you mean by passing to a device?

            – ruohola
            Mar 8 at 10:00













            @WillJames see my edit

            – ruohola
            Mar 8 at 12:07





            @WillJames see my edit

            – ruohola
            Mar 8 at 12:07













            thanks I figured it out last night and I put my solution below.

            – Will James
            Mar 8 at 17:12





            thanks I figured it out last night and I put my solution below.

            – Will James
            Mar 8 at 17:12













            @WillJames feel free to mark my answer as accepted if you feel that it provided a good solution :)

            – ruohola
            Mar 8 at 17:15





            @WillJames feel free to mark my answer as accepted if you feel that it provided a good solution :)

            – ruohola
            Mar 8 at 17:15













            0














            Ok I figured out by appending the first and last name and creating a list for the found criteria. I then converted the list to a string to display it on the device.



             full_list = []

            my_snapshot = cfm.child('teamMap').get()
            for players in my_snapshot:
            if players['age'] != 27:
            full_list.append((players['firstName'] + " " + players['lastName']))

            send_message('n'.join(str(i) for i in full_list))





            share|improve this answer



























              0














              Ok I figured out by appending the first and last name and creating a list for the found criteria. I then converted the list to a string to display it on the device.



               full_list = []

              my_snapshot = cfm.child('teamMap').get()
              for players in my_snapshot:
              if players['age'] != 27:
              full_list.append((players['firstName'] + " " + players['lastName']))

              send_message('n'.join(str(i) for i in full_list))





              share|improve this answer

























                0












                0








                0







                Ok I figured out by appending the first and last name and creating a list for the found criteria. I then converted the list to a string to display it on the device.



                 full_list = []

                my_snapshot = cfm.child('teamMap').get()
                for players in my_snapshot:
                if players['age'] != 27:
                full_list.append((players['firstName'] + " " + players['lastName']))

                send_message('n'.join(str(i) for i in full_list))





                share|improve this answer













                Ok I figured out by appending the first and last name and creating a list for the found criteria. I then converted the list to a string to display it on the device.



                 full_list = []

                my_snapshot = cfm.child('teamMap').get()
                for players in my_snapshot:
                if players['age'] != 27:
                full_list.append((players['firstName'] + " " + players['lastName']))

                send_message('n'.join(str(i) for i in full_list))






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Mar 8 at 7:11









                Will JamesWill James

                84




                84



























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55055934%2fshould-i-append-or-join-a-list-of-dict-and-and-how-in-python%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme

                    Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

                    2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived