Two files with the same name
Predict the output · Basic · §9.5 Where is it, and how is it written?
There is a likes.txt in the current folder and another likes.txt inside the data folder. Predict the output without running the code.
Code
with open("data/likes.txt", "w", encoding="utf-8") as f:
f.write("300\n")
with open("likes.txt", encoding="utf-8") as f:
a = int(f.read())
with open("data/likes.txt", encoding="utf-8") as f:
b = int(f.read())
print(a, b)File likes.txt
100File data/likes.txt
250Solve this problem in your browser
Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.