Fill in the blanks to read the content of a file called "records.txt" and output the number of characters it has. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Fill in the blanks to read the content of a file called "records.txt" and output the number of characters it has.

Hello, i need your help to solve this application: f=open("records.txt","r") cont = f.read() print( (cont)) f.close(() What I should put in the space between print and cont?I have read all theory and I tried but nothing works.Could you give me an idea please?Thank you!

14th Jun 2021, 10:04 AM
Cristina
7 Answers
+ 2
f=open("records.txt","r") cont = f.read() print( len (cont)) f.close(()
20th Feb 2022, 11:22 PM
Liria
Liria - avatar
+ 1
len() to count number of character of a string.
14th Jun 2021, 10:07 AM
TOLUENE
TOLUENE - avatar
0
you also may want to use the full path for the file name and use the correct amount of parenthesis in f.close()
14th Jun 2021, 10:16 AM
Slick
Slick - avatar
0
Thank you so much for for answers
14th Jun 2021, 10:41 AM
Cristina
0
Can someone say the answer? I don't understand
14th Jan 2022, 11:10 AM
Thuwayba Ahmed
Thuwayba Ahmed - avatar
0
Thuwayba Ahmed so go through the lesson again or ask your own specific question. We don't just tell you the answer you have to figure it out yourself as the OP did.
14th Jan 2022, 11:12 AM
Slick
Slick - avatar
0
print(len(cont))
19th Dec 2023, 11:46 AM
Jesus