Is there a way to track badwords in variable in input in python

I want to track badwords like english badwords and i don’t want to use: if intext.find(‘badword’) != -1: print(“That’s a badword”) because it is lengthy and i also don’t want to include …

How find index where the item length less than x in python

for example i have a list which contain: [‘Lorem Ipsum is simply dummy text of the printing and typesetting industry.’, ‘Why do we use it?’, ‘Where does it come from?’, ‘The standard chunk of Lorem …

Python, adding a different characteristic to each element of a list

i am currently working on a producion optimization tool. There are Jobs who needs to be produced on machines. I want to add a workspeed for the machines so they can finish the jobs in a different …

How to convert string of list of list to list?

I have this file, it is the result of the MapReduce job so it has key-value format: ‘nullt[0, [[0, 21], [1, 4], [2, 5]]]n’ ‘nullt[1, [[0, 3], [1, 1], [2, 2]]]n’ I want to remove all the character …

What makes the difference by creating a set in this code?

Given a list of numbers and a number k, return whether any two numbers from the list add up to k. For example, given [10, 15, 3, 7] and k of 17, return true since 10 + 7 is 17. Bonus: Can you do this …

How to replace several values of a column using lists in python

I have a dataframe name “detalhe” with several columns and one is named: “Concelho”. I have a list of unique values of “Concelho” named “Concelho ADENE” and I …

how to split a list of numpy arrays and concatenate arrays of euch sublists in python

I have a list of numpy arrays and want to firstly split the list and then concatenate all the arrays exiting in each sublist. Number of sublists is defined by: n_sublist=2 # but in reality I have much …

How to create a new list of all the words separating by each word and each line?

I have a text file as : sample.txt Hi I am student I am from What I’ve tried is import string import re def read_to_list1(filepath): text_as_string = open(filepath, ‘r’).read() x = re.sub(‘[…

How do you remove corresponding x values of missing y-data from lists?

import matplotlib.pyplot as plt #for graphing data import numpy as np plt.figure() x = col1 = [2011.005, 2012.6543, 2013.3456, 2014.7821, 2015.3421, 2016.7891, 2017.0173, 2018.1974] col2 = [1.4356, &…

python transform 1d array of probabilities to 2d array

I have an array of probabilities: l = [0.9, 0.2, 0.4] and I want to make it 2d array: l = [0.9 0.1 0.2 0.8 0.4 0.6] What is the best way to do so? Thanks!