简体   繁体   English

任何说明子列表[即某物] 是否存在于列表中的函数?

[英]Any function which says if a sublist[i.e. something] exists inside a list or not?

Is there any simple function which says if a sub-list [ie Something or Anything] exits within a list or not ?是否有任何简单的函数可以说明子列表 [即某物或任何东西] 是否存在于列表中?

For Example: a.例如: a. Says there is a top list, ie top_list = [] b.说有一个顶级列表,即top_list = [] b。 Next check if some sub-list exits or not ie if top_list[0] exits or not ?接下来检查某些子列表是否存在,即 top_list[0] 是否存在? Something like, top_list is [[]].就像,top_list 是 [[]]。 That sub-list can be just an empty list [] or a list with some number etc..该子列表可以只是一个空列表 [] 或带有一些数字等的列表。

Just wanted to find if a sub-list exits within a list or not ?只是想查找子列表是否存在于列表中? Kindly drop in your comments if you have any suggestions.如果您有任何建议,请留下您的意见。

Thanks in Advance, Vimo提前致谢, Vimo

This: https://stackoverflow.com/a/5148526/6194839 will check for a non-sequential list.这个: https : //stackoverflow.com/a/5148526/6194839将检查非顺序列表。

Checking for a sequential list I would just brute force it, looking through the list for an entry that matches the first in your sub-list, then checking for the rest.检查顺序列表我只会强制执行它,在列表中查找与子列表中的第一个匹配的条目,然后检查其余的条目。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果该子列表中的任何元素在另一个列表中,如何删除列表中的列表(即子列表)? - how to delete a list within a list (i.e., a sublist) if any element of that sublist is in another list? 哪个更快? 检查某些内容是否在Python列表中? 即会员资格与非会员资格 - Which is faster? Checking if something is in a Python list or not? I.e. membership vs non-membership 如何在 class 内部创建一个 function ,它可以告诉最大属性(年龄)及其对应的属性到这个最大年龄(即名称)? - How to create a function inside the class which can tell maximum of an attribute (age) and its corresponding attribute to this max age (i.e. name)? 将删除其他列表**内部**的每个子列表的函数 - function that will remove every sublist that is **inside** of other list 在列表中的字典子列表中计算等级 - count grade inside sublist of dictionary which is inside a list 如何在 pygame 中更新接收函数即 lambda 的 Sprite? - How to update a Sprite in pygame which takes in a function i.e. lambda? 如何检查列表(Python)中是否存在子列表的某些元素? - How do I check if some elements of sublist exists in list (Python)? 如果子列表中存在术语,如何将其仅追加到另一个列表? - How can I append a sublist only to another list if a term exists in it? 如何从包含键作为字典列表的字典中获取第一个键值对(即“类型”:45) - How do i fetch first key value pair (i.e., 'type': 45) from a dictionary which contains key as list with dictionaries 如何创建每个CSV行的子列表并将该子列表放在列表中 - How do i make a sublist of every CSV row and put that sublist inside a list
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM