I’m new at programming and i need help with my “work”. I need to print specific number from a list. List = from 1 to 10 000 and i need to pick every single number that has “375” as a last three digits For example: 375, 1375, 2375 etc. My english isn’t the best so I hope you undestood me
Tag: list
Compare two lists and write for each item corresponding X column value
Let’s say I have a list of users then I have a table What I want is: to have a list of Date for each Resource A, B, C So desired output could be a dictionary: Answer You can use explode then use groupby and agg(list) at the end get the result as dict with to_dict. Output:
Why am I getting TypeError: list indices must be integers or slices and not the float value while finding Median of two sorted arrays?
I have two sorted arrays and I am trying to find median of two sorted arrays.For example,if input is nums1 = [1,3], nums2 = [2] then the output will median=2.00000 and if the input is p = [1,2], t = [3,4] then the output will be median=2.50000 I have added both the arrays together and sorted them and later by
how do I return a list containing print statements?
So i am working on this function that takes a list as a parameter containing positive int, negative int, and the number 0 (zero). I have written the function using a while function with nested if statements to determine the value of each integer. Here is an example: My question is how do i return each print statement in a
I want to convert file data into 3d dictionary using python
Like I want this type of dictionary by reading file: or this will be enough. I have a file lets name file.txt which has data like I am trying but i dint get the result this following is my try: it gives me output {‘A’: ‘7’, ‘B’: ‘8’, ‘C’: ‘9’} I know its obvious it will not give me 3d
New list based on indices from another list in Python
I have an array X and a list A1. I want to create a new list B1 such that it consists of values from X corresponding to indices in A1. For example, the code should pick values from X[0] for indices in A1[0] and so on…I present the current and expected outputs. The current output is The expected output is
Creating multiple sublists in Python
I have a list J with len(J)=2. I want to create a sublist of each element in J[i] where i=0,1. I present the current and expected output. The current output is The expected output is Answer you can try this, this will give you [[[1], [2], [4], [6], [7]], [[1], [4]]]
Merging two lists in a certain format in Python
I have two lists A and B. I am trying to merge the two lists into one in a specific format as shown in the expected output. I also show the current output. The current output is The expected output is Answer Or as @Mechanic Pig suggested in comments using list comprehension:
count number of missing items required comparing dictionaries in python
Given a list: a dictionary with ingredients I currently have: and a more complex dictionary with the recipes and items per ingredients: I want to output a dictionary that adds to the elements of the list list_essentials the number of items I need if I wanted to be able to make all the recipes. The expected output I am looking
Keeping the structure of a list in after operating a nested loop
Suppose I have two lists as follow: I want to add each element of list x with each element of list y while keeping the structure as given in x the desired output should be like: So far I’ve done: where res produces the sums correctly but I am losing the structure, I get: Also is there a better way