How can you erase a particular value in the list?
The value of the list exists.
review_list = ["14hour","16hour","20hour","24hour","8hour","4hour","2hour","hello","jae12"]
If you look at the list value,
Only numeric values change before int(1-24)hour.
How can you remove int (1-24)hour and output the remaining values?
OUTPUT
review_list = "hello","jae12"]
Advertisement
Answer
Based on your expected output, you want to remove elements which contain “hour” in the value
review_list = ["14hour","16hour","20hour","24hour","8hour","4hour","2hour","hello","jae12"] review_filtered = [x for x in review_list if "hour" not in x]
Output
["hello", "jae12"]