list

How to filter elements in a list that occur only once

How to filter elements in a list that occur only once Question: I need to filter and discard elements in a list that have single appearances. Hi, how to filter out from a list of elements the elements that occur only once? I have the following list of integers as input. I need to make …

Total answers: 2

Unravel a tree structure stored as nested list

Unravel a tree structure stored as nested list Question: I’m working on a piece of code which simulates possible paths through a series of nodes. The nodes are assigned numbers and the connected nodes are listed in a lookup table. Since the path sometimes splits in two (or many) possibilities (and sometimes only one, i.e., …

Total answers: 1

Making list from elements from each level of a nested list

Making list from elements from each level of a nested list Question: I have a list: cleaner = [[‘Re:’, ’31_300323′, ‘RE777′]] I want to check if another list contains same value, I write: any(’31_300323’ in sl for sl in cleaner) , and get "True", but if I write: suka = [] for h in cleaner: …

Total answers: 2

Divide Python list into multiple lists based on element condition

Divide Python list into multiple lists based on element condition Question: How can I take a python list and divide it into multiple lists based on element conditions? myList = [‘Georgia’, 12344, 52353, ‘Alabama’, 352947, 394567, 123437, ‘Florida’, 992344, 788345] for each in myList: do stuff result: list1 = [‘Georgia’, 12344, 52353,] list2 = [‘Alabama’, …

Total answers: 1

having trouble with appending in nested lists in python

having trouble with appending in nested lists in python Question: I am having trouble with appending to a nested list in python. It keeps giving me a final list with double the list size it should be. When I loop through the second loop the first time it gives me an list with eleven elements …

Total answers: 1

How to import data form lists in a dictionary in Python?

How to import data form lists in a dictionary in Python? Question: I want to create a program that takes 3 different inputs and stores them in 3 separate lists and then be able to combine them in a dictionary and print on screen. So far I got this : size = input("Enter size of …

Total answers: 1

New to python. I need help assigning numerical values to an email list

New to python. I need help assigning numerical values to an email list Question: I am currently taking my first python class and I need help assigning numbers to an email when it is added to my list of emails. That way when someone wants to remove an email from the list, they can see …

Total answers: 1

How do I access using Python Dict and List

How do I access using Python Dict and List Question: Here I am giving two variables namely "a", "result". If "result" matches with any of the record in "a" in "city" then it should return entire record of the "a" variable. a = { "output": [ {"name": "India", "state": [ { "city": ["c", "d" ] …

Total answers: 2

Cant find a variable in a list

Cant find a variable in a list Question: I wrote this code as a part of a course I am taking right now, and even though I asked some friends to debug it we didn’t manage to find the problem in the code. It throws an error that the variable I am looking for cannot …

Total answers: 1