How do I remove a specific string from some strings in a list?

I’ve been trying to figure out a more universal fix for my code and having a hard time with it. This is what I have: lst = [‘Thursday, June ##’, ‘some string’, ‘another string’, ‘etc’, ‘Friday, June ##’, ‘more strings’, ‘etc’] I’m trying to remove everything after the comma in the strings that contain commas… Read More How do I remove a specific string from some strings in a list?

How can I remove element from list?

Attempts to remove characters from the string that are not numbers. Unfortunately, I cannot do this due to a reason. I also tried "del file[i][j]", unfortunately without. Code: file_open = open("napisy.txt","r") wyniki = open("wyniki4.txt","w") file = file_open.read().split() file1 = file print(file) cyfry = [‘0′,’1′,’2′,’3′,’4′,’5′,’6′,’7′,’8′,’9’] cyfry_zad3 = ” licznik_cyfr = 0 tab = [] for i… Read More How can I remove element from list?

Taking the union of 2 lists of lists in Python

I have 2 list of lists. One is say list1, which is : [[‘1’, ‘2’, ‘*’, ‘2’, ‘1’, ‘0.8’], [‘1’, ‘2’, ‘3’, ‘1’, ‘1’, ‘0.7’], [‘*’, ‘*’, ‘3’, ‘4’, ‘1’, ‘0.5’], [‘1’, ‘2’, ‘*’, ‘1’, ‘1’, ‘0.3’], [‘2’, ‘2’, ‘*’, ‘2’, ‘1’, ‘0.1’]] And list2 is : [[‘3’, ‘*’, ‘1’, ‘4’, ‘1’, ‘0.9’], [‘1’, ‘2’,… Read More Taking the union of 2 lists of lists in Python

How to print an error saying that an integer must be entered if either input value is not a number, and multiply x by y when no error is caught

I am trying to make it so that if either input value is not a number, it will print an error message saying that an integer must be entered. And whenever no error is caught, it will multiply x by y. How would I do this? Here is what I have so far: def main():… Read More How to print an error saying that an integer must be entered if either input value is not a number, and multiply x by y when no error is caught

Using elif statement "print function" not working correctly instead printing if statement's "print function" instead

I am trying to make a selection tool to pick my next anime, I used the random package to select which one would be the next to watch and this works correctly my issue lies in the following I want to add a description to the selected show, for example, if it picks show b… Read More Using elif statement "print function" not working correctly instead printing if statement's "print function" instead