sentence = "ASK NOT WHAT YOUR COUNTRY CAN DO FOR YOU ASK WHAT YOU CAN DO FOR YOUR COUNTRY"
positions = [s.index(x)+1 for x in s]
with open('task_2.json', 'w') as f:
with open('task_2.json', 'w') as f: closes the file after the indented code runs. This means that you don't need the
f.close() line. Using a
with statement in python is just a safer way to work with files.