Explanation
Line 1 was
file = open("data.txt", 'r'')
but it should be
file = open("data.txt", 'w')
Changing 'r' to 'w' makes it possible to add text to the text file.
Python Mega Course: Learn Python in 60 Days, Build 20 Apps
Learn Python on Udemy completely in 60 days or less by building 20 real-world applications from web development to data science.
