索引列表中的特定项目

问题描述 投票:0回答:0

如何使用此随机数据集中的代码索引以下项目:

    Move number (0,1,2,3 etc) in all lines

第一行 - 值“3” 第一行 - 起始方向(字符串)'South east'

 In the remaining lines -the movement instruction (character string)' Move & turn left' etc.


    [[0, 3, 'South east'],
    [1, 'Move & turn left'],
    [2, 'Move & turn right'],
    [3, 'Move & turn left'],
    [4, 'Move forward'],
    [5, 'Move & turn right'],
    [6, 'Move & turn right'],
    [7, 'Move & turn right'],
    [8, 'Move & turn right'],
    [9, 'Move & turn left']]

我试过使用打印语句来识别列表项

    print(function_name [0][2]) to return what is item is being identified etc.

不确定是否需要切片来返回我特别想要的东西。

indexing slice
© www.soinside.com 2019 - 2024. All rights reserved.