Reading files | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Reading files

file = open("books.txt", "r") file.write("Harry Potter\n," "Parvana\n") for i in file.readlines(): print (i) file.close()

14th Feb 2022, 2:39 PM
Knowledge Is Power
Knowledge Is Power - avatar
2 Answers
+ 2
You can’t write using read mode.
14th Feb 2022, 3:51 PM
hamishhr
hamishhr - avatar
0
How do i use the text to read from a file and print the number of strings and first letter of the book title..
14th Feb 2022, 4:43 PM
Knowledge Is Power
Knowledge Is Power - avatar