Skip to content
Advertisement

Tag: list

Trying to convert input to list

I’m trying to take input from user for 2 points and output the distance. I’m getting stuck on converting the input to a list for the output. I might be thinking about it the wrong way, any help to get me in the right direction is appreciated. Answer You can use a list comprehension to translate the inputs into ints

How to change list elements positions in a for loop in Python

I’m fairly new to programming and I’m really stuck in a problem. Say I have the following list: The list might contain more elements. What I need to do is change positions between “**” and “@”, so I would have I’ve been trying to do it with a for loop, using element indexes to perform the change, but the list

Appending two lists with multiple dicts Python

I have five dictionaries dic1, dict2, dict3, dict4, dict5. I’m trying to append dict-keys to two lists list1, list2. Output The first three dictionaries are to be appended for both the lists and fourth dictionary dict4 to the list1 and fifth dict5 to the list2. So far I did in this approach, I’m looking for an efficient and better approach

assign key as list index+1 to list of tuples [closed]

Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question I have a list of tuples and I want to convert them to dictionary but the key should be tuples index in the list+1 So

Python To-Do List List/Loops

Been having some trouble with trying to make this to do list code. I’m trying to Write a program that will prompt the user to enter an item for their to-do list. Each item is then added to a list. When the user enters no input, the program will display the to-do list in two columns. The thing is though

Checking if list element in list of lists and returning sublist

I have two lists and want to return those sublistst of list2 that contain elements of list1. So far I tried using any: and a naive approach But I only managed to repeat empty list. The result should be Not sure, where I’m going wrong. Is there maybe a way using list comprehensions or mixing list comprehensions and ‘any’ function?

Advertisement