Q. What will this code snippet output?
file = open('file.txt', 'w')
file.write('Hello')
print(file.tell())
Code:
file = open('file.txt', 'w')
file.write('Hello')
print(file.tell())
file = open('file.txt', 'w')
file.write('Hello')
print(file.tell())
β
Correct Answer: (B)
5
Explanation: tell() returns the current position which is the number of characters written.