I have a list. I want to trim the strings in the list to remove the characters including . sign and the numbers. Expected output: Answer You can use regex with pattern as r’.d+’. This will literally match . followed by one ore more digits.
Tag: list
Iterate through an adjacency matrix with a list
So I have a n x n adjacency matrix, N x N NumPy array, where the i-th row and the j-th column is the distance between the i-th and j-th cities. I also have list, in a specific order in which I have to visit the cities and and add the distances together. The list items are pointing to row/column
How to make a for loop iterate a list and ask for input? PYTHON
I would like to make a program that asks how many bills of each type you got, to do this I wanted to use a for loop and a list. I did this little test: This only prints, not all three choices as I want: And when I give any input it gives me this error: ValueError: invalid literal for
Question about turning a list of numpy arrays into an object array
I have a question about turning a list of numpy arrays into an object array. This results in two very different outcomes: I assume that the difference comes from the fact that in testing_2_array not all arrays have the same size. Is there any way to force numpy to output testing_1_array in the same way as testing_2_output so that I
Creating a list with user input? Sales program, enter sales for 7 days
So the problem is this: Design a program that asks the user to enter a store’s sales for each day of the week. The amounts should be stored in an array. Use a loop to calculate the total sales for the week and display the result. This is what I have so far, I know it’s in issue with bounds,
Pop or Delete a Dictionary item from list
I have this list of dictionary items. I want to delete a specific dictionary entry from the list by comparing it with a dictionary item I have a variable I would like to do, To get, Answer It seems that you are trying to delete a tuple of items. Your to_delete is actually a tuple of dictionaries, so to delete
Trying to show all numbers lower than the average in another list
For school we have to make a code which shows the average of a certain list into another list but for some reason my list which should show the smaller numbers is empty, I don’t know if it is possible but I tried using an extra variable which counts +1 to itself help is appreciated in advance. Answer 2 things:
I couldn’t make a list with these codes in python [closed]
Closed. This question needs debugging details. It is not currently accepting answers. Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question. Closed 1 year ago. Improve this question I couldn’t make a list with these codes in python Answer Use glob.glob()
How can I compare two lists and m python. – Capture the different value
I am trying to compare two lists in python, one of them is a response from a rest request that I stored in a list and the other is obtained through a csv file. I need to compare them and capture the values that do not exist in the first list that is obtained from the csv that is smaller
Iterating Through List of Lists, Maintaining List Structure
Say I have the following list of list of names: I want to return only the “Matts” in the list, but I also want to maintain the list of list structure. So I want to return: I’ve something like this, but this will append everthting together in one big list: I know something like this is possible, but I want