简体   繁体   中英

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. Says there is a top list, ie top_list = [] b. Next check if some sub-list exits or not ie if top_list[0] exits or not ? Something like, top_list is [[]]. 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

This: https://stackoverflow.com/a/5148526/6194839 will check for a non-sequential list.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM