Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to write a for/in loop to print the second elements of all the Lists

I have the following lists:

[['Not stated', 128913], ['Response outside scope', 8457], ['Response unidentifiable', 17565], ['Other fuel(s)', 8184], ['No fuels used in this dwelling', 60819], ['Solar power', 603], ['Home heating oil', 24], ['Coal', 19203], ['Wood', 513561], ['Gas', 276666], ['Electricity', 1150047]]

How to write a for/in loop to print the second elements of all the Lists?

I have tried several codes posted in this website and couple others, but didn’t work. I am a new in programming and studying this for my studies.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

As @mkrieger1 suggested:

lists = [['Not stated', 128913], ['Response outside scope', 8457], ['Response unidentifiable', 17565], ['Other fuel(s)', 8184], ['No fuels used in this dwelling', 60819], ['Solar power', 603], ['Home heating oil', 24], ['Coal', 19203], ['Wood', 513561], ['Gas', 276666], ['Electricity', 1150047]]

for item in lists:
    print(item[1])
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading