Kellen A.

asked • 12/23/22

Computer Science. Why doesn't this work?)

f = open("data.txt")

a = 0

for line in f:

a = a + len(line)

print(a)



Daniel B.

tutor
When I run it, it prints the total number of characters in data.txt, including newline characters. Did you want it to do something different?
Report

12/23/22

2 Answers By Expert Tutors

By:

Michael F. answered • 12/30/22

Tutor
4.8 (44)

30 years college professor of undergraduate math and computer science

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.