for example i have this string : ch = “promotion bac 2019” and an empty list : t=[] i want to make the list get each word separately using the empty spaces result will be : t=[“promotion”,”bac”,”2019″] i tried deleting each word from the string after storing it …
Tag: list
Remove elements from tuple array that have same value in first index position of each element
Lets say I have a list: There are two tuples with ‘a’ as the first element, and two tuples with ‘c’ as the first element. I want to only keep the first instance of each, so I end up with: How can I achieve that? Answer You can use a dictionary to help you filter the duplicate keys:
Why is it saying my variable is not subscriptable?
I sometimes get this error (TypeError: ‘NoneType’ object is not subscriptable) when I call getLink()[0], and I sometimes don’t. Does anyone know why I’m getting this error? getLink() should be subscriptable… EDIT: my issue was I needed a longer time.sleep() waiting function to gi…
list comprehension, how to append the new elements to the list?
am working on my Python assessment and I need a hand :( so, the task is to use this equation: 10*x-5 and print positive numbers only; the task focuses on using list comprehension, finally, I’ve to print the updated list. I did all of that but i couldn’t figure out how to insert/append the updated …
How to get a count of specific element in nested list python
so I want to get the count of ‘expert’ and ‘user’ from every row of data frame and from every list. And after getting a count of experts and users, I want to store the respective ids in another list. I have tried converting them into the dictionary and calculate using key but it is not…
Why am I getting error after looping into file and trying to join the list
I have large text file which has numbers. I want to loop through the file and append the numbers to the list_of_numbers. Problem is that the loop appends to the list but not in the way I want, that’s why the list looks like this after iteration this is just part of the output. I want this to be in
python: split a list of strings based on a condition
I have a list like the following: I would like to split the list in a way to get the following output. I have tried the following but do not get the result i am looking for. Answer Almost. First of all, the following produces what you want – More specifically, it seems you want to split by a space-chara…
Make a lists of list with excel values and sort by sheets
I would like to make a lists of list with excel values. I have multiple excel sheets where there is always 1 same data,and i want to put the datas into lists. Here is an example: In the Sheet1 these are the datas: And at the Sheet2 these are the datas: In my code i find the 1Data and after
create a csv with the Items missing on the latest file
I am trying to create a csv with the Items missing on the latest file log. the comparing files are out.csv wish is a scan result, and the latest csv on the log folder. the idea will be not repeating the rows already used before as the out.csv will have always the full content I have not a clue why
Is it possible to store each line of a .txt into as a list and then use it later?
Im new to Python and trying to do some code on my own. I’d like to take input from a .txt file and then store each line of that .txt into a different list. For example, if the file has 2 lines, I want to do something like this: .txt file: python output: I tried working with loops for extracting