Skip to content
Advertisement

Tag: nested-lists

Trying to find unique subarrays and sub-elements?

I have an array will subarrays containing [page_name, url, and id] in dirty_pages. This array contain duplicate subarrays. I need to parse each subarray in dirty_pages into clean_pages such that: there are no duplicates (repeating subarray) the 1st index in the subarray i.e. the url must be unique! For example This url should be counted as one (url/#review is still

Finding index in nested list

I am trying to create a function that will take as input a nested list and an item, and return a list of indices. For example list = [0, 5, [6, 8, [7, 3, 6]], 9, 10] and item = 7 should return [2, 2, 0], since list[2][2][0] = 7 my code should work since I can print the desires

Read input as nested list in python

I am new to python. I want to read the input from stdin as nested list. Stdin: My list should be as follows: Is there any way I can read the input using list comprehension without needing any extra space. Answer This is one way.

Print list of lists in separate lines

I have a list of lists: I want the output in the following format: I have tried it the following way , but the outputs are not in the desired way: Outputs: While changing the print call to use end instead: Outputs: Any ideas? Answer Iterate through every sub-list in your original list and unpack it in the print call

Advertisement