I have a text full of adverbes and it’s replacements like this : And i want the adverbes to replaced in my text: Example : but am runing out of solutions, my code so far: I couldn’t find a way to replace each adverbes with the appropriate replacement. the list_adverbes_replacement.txt is the text …
How to do a multi level sort on list of lists in Python? [duplicate]
This question already has answers here: How to sort a list with two keys but one in reverse order? (8 answers) Closed 5 months ago. I have the below code: With this the output is: I’m trying to display the names in Descending order while the values in Ascending order. Is there a pre built way in python …
Python – Pull Out Values from Only Dictionaries that Meet a Certain Criteria
I have a Python list called “results” that has dictionaries as its values: How would I create a list that gets all the values from the dictionary where the ‘boardID’ value is ‘_internal’ (but ignores the dictionary where ‘boardID’ is ‘_external’)? As…
Python exception: execute code if a specific exception is raised or else
Let’s say I have the following code, that assign 1 and print it in case the value is None or not negative. Is there a way to avoid repeat twice to assign value=1 and print it? It would be ideal something like except NotFound or else, but I have not found anything similar in python. Answer There is no ex…
Color values for opencv detection
This is a basic Detection of a specific color script in python taken from here. I am trying to work with “#34659F” color. I checked the above values, and they dont correspond to blue region. I check both the uppler and lower values and found that they dont correspond to blue values. I tried to sel…
How to write a xls table to docx using Jupyter python
Hello I am new users of Jupyter python and I have a question: I have data in xls sheet and I want to write some of the columns in words docx by using python. I have 12 columns and I want only 3 in docx file. Answer In Windows, name the range of the 3 columns you’re trying to copy
count how many people join in 1st half and 2nd half
the output I want that is like in the year 1980 people who join in 1st half and 2nd half in dictionary form like this {1980:{H1:3, H2:0}, 1981:{H1:7, H2:8},…..} Answer You’re close, but you need to set 0 somewhere, and accumulate some results
How can I count the depth in a list of lists?
I want to count the depth in a list of lists, so not the amount of elements but the maximum depth one list can have. This is my function: should return 4 Answer You can try: Output: Explanation: First check if object passed into the recursive function is of type list: If so, proceed to add up the Trues in
Change substring in a string to an corresponding item in a dictionary using Python
I get a string like “29 jan. 2021”. I want to convert the swedish substring “jan.” to the corresponding english month name, in this case “Jan” so the result would be “29 Jan 2021”. Then I can use this string to convert it into a date object. I have a dictionary …
How to create a proper CheckButton in Tkinter?
Im trying to create a CheckButton in tkinter based on the items I have in my equipment list. The CheckButton has been created but not all the items that are in equipment are visible in the app. Is it because my items are to large? This is my code: This is how the tkinter app looks like: Answer This happens,