-1

I would like to adapt a Python 3.10 script. Here I have the reading of a file where per line only one word is stored:

def readKeywords():
    with open(keyword_path, 'r') as f:
    return [keyword.strip() for keyword in f.readlines()]

Now I would like to change this function so that I can read 4 words which are stored in the file in the line.

E.g.

Walter Josef Jane Tom
apple banana tomato potato

the used variables should be keyword1 keyword2 keyword3 and keyword4.

Walter Schrabmair
  • 1,030
  • 2
  • 10
  • 24

0 Answers0