Using an index to get an item, Python

前端 未结 5 1314
轮回少年
轮回少年 2020-11-30 10:23

I have a tuple in python (\'A\',\'B\',\'C\',\'D\',\'E\'), how do I get which item is under a particular index number?

Example: Say it was given 0, it would return A

5条回答
  •  南笙
    南笙 (楼主)
    2020-11-30 10:35

    You can use pop():

    x=[2,3,4,5,6,7]
    print(x.pop(2))
    

    output is 4

提交回复
热议问题