Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从第二个位置有“I”的列表中找到单词?[Python]_Python_List - Fatal编程技术网

如何从第二个位置有“I”的列表中找到单词?[Python]

如何从第二个位置有“I”的列表中找到单词?[Python],python,list,Python,List,在Python中,如何从第二个位置有I的列表中查找单词 example_list = ['one','two','three','four','five','six','seven'] 我想找到第二个位置有I的所有单词 the output should look like this: ['five','six'] 这可能吗?使用索引检查条件。字符串也可以像列表一样被索引,比如在字符串中s='python',s[0]是'p',s[1]是'y' [i在示例_列表中表示i,如果i[1]=“i”]

在Python中,如何从第二个位置有I的列表中查找单词

example_list = ['one','two','three','four','five','six','seven']
我想找到第二个位置有I的所有单词

the output should look like this: ['five','six']
这可能吗?

使用索引检查条件。字符串也可以像列表一样被索引,比如在字符串中s='python',s[0]是'p',s[1]是'y'

[i在示例_列表中表示i,如果i[1]=“i”]
如果单词少于2个字符怎么办?将出现索引器错误@Thrasi@Thrasi重点是我并不是在处理所有的情况,有可能示例列表将包含一个数值。我应该解决OP提出的问题。虽然您不必处理诸如类型验证之类的所有事情,但是任何健壮和有用的代码都会考虑任何长度的列表。
['five', 'six']