Skip to content
Advertisement

Tag: list

How to convert ‘+’ into + in Python

I’m willing to make a program that evaluates all possible combinations of operations ( + , – , * , / ) on a set of positive integers of length 6 (eg : [1, 6, 3, 9, 2, 9] ). To do so, I am using the list and wrote a nested loop to create all possibilities by calling each

Comparing two lists with specific values to read

I have two lists and when I loop through the list and I managed to get the difference, but I need time as well because it is a separate item and ‘uvz’ does not mean to me anything in the list with a few thousand entries. I tried to convert it to the dictionary, but it overwrites with the last

loop in a list of lists

I am trying to use two foor loops for a variable with that has list within a list, but this code doesn’t work. I get the error: list index out of range Answer In your loop, j is not an index, it’s the element, you can use range to loop over the indices (same thing about i, use i[j], not

Find how many numbers two numbers have in common

So I’m trying to make a program that tells the user how many numbers both inputted numbers have in common FOR EXAMPLE: if inputted n1 = 765 and n2 = 572 then the program returns 2 because both numbers have 7 and 5 in them. I made this but it isn’t working: Answer Use list comprehension and sets instead, like

Discord.py read list

I have a file with a list called wbanned.txt which contains forbidden words. I want every message sent to be read and if it contains one of the forbidden words in the txt list (Every word is on a new line from list) to be deleted. I tried something but all it does is delete it only if it contains

Advertisement