I have a list of words as an output,
data = ['1', '60s', '80s', 'metal', 'garage rock', 'adult alternative pop rock']
.
From this list, I would like to replace specific values with the value 'rock'.
I have list of values that I want to replace with 'rock', namely rocklist = ['metal', 'garage rock', aldult alternative pop rock']
. I want to delete the other values from the list.
I tried to do the following:
replace= ['rock' if x== rocklist else x for x in data]
``'print(replace)'''
but this didn't work. How should I go about this?