I am writing a Python 3.x program that reads from a text file, extracts the necessary information, and performs further processing.
The linked question does not solve my problem, I am aware of how to use Google and have tested that code, it DOES NOT WORK.
I have a variable, pointStore, which contains only integers. I am unable to find a solution where I can extract only the elements I need from this list or a solution that would allow me to remove corresponding elements in other lists as well. Take for example I am collecting phone numbers in one list, names in another list, and addresses in the third. If I remove an element from one, I would like to remove its corresponding elements in other lists. How would I go about doing this if I can't even get the values I need in the first place?
I think a messy solution would be to write pointStore line-by-line to a file, read that file, and iterate over it line by line only grabbing the elements I need but I would like to write cleaner code.
I've looked around quite a bit on several different websites including Stack Overflow and I can't find an answer that actually solves MY problem or an answer that can be applied to my problem.
def function():
userInput = input("Enter a cutoff value: ")
for element in myList:
if element < userInput:
myList.remove(element)
When I try to run the code above, it removes some values from the list, but not in accordance with the criteria I set, ex. I specified 5000, it removed 1800 but not 3882.
I expected the program to iterate over the list myList and remove values that are less than the user's input, stored in userInput.