Python で分割と結合を理解していると思っていましたが、うまくいきません。
の値を言ってみましょうinp[17] = 'Potters Portland Oregon school of magic'
# a string of data I am pulling from a csv file, the data comes through just fine.
loc = inp[17]
l = loc.split(' ') # I want to split by the space
# I want to filter out all these words say they don't always
# come as "School of magic" so I cant just filter that out they
# could be mixed around at times.
locfilter = ['Potters', 'School', 'of', 'magic']
locname = ' '.join([value for value in l if l not in locfilter])
この時点で、私のlocname
変数にはそれしか含まれていないはずですがPortland Oregon
、まだ'Potters Portland Oregon school of magic'
除外されていません。
問題は私のlocname =
行にあると思います。
助けてくれてありがとう。