Click here to Skip to main content
15,889,116 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How do I access the row names from this array?

What I have tried:

Python
data = [
    ["Fruit", "Quantity"],
    ["Kiwi", 3],
    ["Grape", 15]
]

for r in data:
    print(r)
Posted
Updated 27-Apr-18 0:06am
v2

1 solution

The loop for r in data means r will hold e.g. ["Kiwi", "3"].

If you want to have "Kiwi", you can use data[1][0] or r[0]. If you want to have 3, you can use data[1][1] or r[1].
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900