从子列表列表中删除全局列表和索引。 [英] Removing global list and index from a list of sublists.

查看:114
本文介绍了从子列表列表中删除全局列表和索引。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

涉及很多功能,但我会保持简单:





这是我的代码:



There is a lot function involved but im gonna keep it simple :


Here is my code :

[['Musique', 'Initiation au tango argentin suivi de la milonga', 182, 231], ['Musique', 'The Singing Pianos', 216, 216], ['Musique', 'Rythmes et détente : Duo Pichenotte', 216, 216]]





我想只返回每个子列表的索引[1]作为字符串。它是法语,但索引[1]是每个子列表的标题。每个子列表都是一个事件,我只需要返回名称。在我的代码中实际上有更多的事件,但我想要一个简单的代码,并且尽力使用它。



因此,如果我们查看代码示例我给了你我必须回来:





I want to return only the index [1] of every sublist as strings. It's in french but the index [1] is the title of every sublists. Every sublists are an event and i need to return only the name. There is actually a lot more events in my code but i want a simple code and ill do my best with it.

So if we're looking at the code sample i gave you i would have to return :

Initiation au tango argentin suivi de la milonga
The Singing Pianos
Rythmes et détente : Duo Pichenotte



如果有办法让他们返回不同的行,就像我回来一样,那也很棒。



我尝试了什么:



我很难在列表中使用索引子列表。重要的是只返回标题为每个列表的str。我尝试使用了一段时间,比如




If there was a way to return them of different lines like my return, thatd be great too.

What I have tried:

Im having a hard time using index in a list of sublists. It's important to return only the title as str of every lists. i tried using a while like

while i < len(events):

print(events[i][:1])  # That would search every index and return every index i need

但它没有用。有更多的代码涉及但你得到的图片,我不想在这个场景中添加8个函数。

but it didnt work. there is more code involved but you get the picture and i dont want to add 8 functions to this scenario.

推荐答案



有什么问题
What's wrong with
events = [['Musique', 'Initiation au tango argentin suivi de la milonga', 182, 231], ['Musique', 'The Singing Pianos', 216, 216], ['Musique', 'Rythmes et détente : Duo Pichenotte', 216, 216]]

for ev in events:
  print(ev[1])


这篇关于从子列表列表中删除全局列表和索引。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆