How can you erase a particular value in the list?
The value of the list exists.
JavaScript
x
2
1
review_list = ["14hour","16hour","20hour","24hour","8hour","4hour","2hour","hello","jae12"]
2
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
JavaScript
1
2
1
review_list = "hello","jae12"]
2
Advertisement
Answer
Based on your expected output, you want to remove elements which contain “hour” in the value
JavaScript
1
3
1
review_list = ["14hour","16hour","20hour","24hour","8hour","4hour","2hour","hello","jae12"]
2
review_filtered = [x for x in review_list if "hour" not in x]
3
Output
JavaScript
1
2
1
["hello", "jae12"]
2