How to access List elements

前端 未结 5 734
面向向阳花
面向向阳花 2020-11-27 19:30

I have a list

list = [[\'vegas\',\'London\'],[\'US\',\'UK\']]

How to access each element of this list?

5条回答
  •  春和景丽
    2020-11-27 19:56

    I'd start by not calling it list, since that's the name of the constructor for Python's built in list type.

    But once you've renamed it to cities or something, you'd do:

    print(cities[0][0], cities[1][0])
    print(cities[0][1], cities[1][1])
    

提交回复
热议问题