Using an index to get an item, Python

前端 未结 5 1313
轮回少年
轮回少年 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:53

    Same as any other language, just pass index number of element that you want to retrieve.

    #!/usr/bin/env python
    x = [2,3,4,5,6,7]
    print(x[5])
    

提交回复
热议问题