Skip to content

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 th…

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 i…

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 l…

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 tuple…

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