+ 1

Can you help me about Book Library pro solution?

My code make the expected output. But it's not approved! file = open("/usercode/files/books.txt", "r") #your code goes here library = file.readlines() a = 0 for i in library: book = library[a] a = a + 1 first = book[0] second = len(book) if a == 3 : break print(str(first) + str(second - 1)) print(str(first) + str(second - 1),end='') file.close()

31st Oct 2020, 8:58 AM
Mohammad Hosein Nosrati
Mohammad Hosein Nosrati - avatar
1 Answer
0
If you are having problems with opening the .txt file, then try to open file using "with open" statement. It will close the file automatically after reading the data from the file. The rest of the problem can be with you for loop. In that loop, you didn't use "i" from "for i in library:" statement.
4th Nov 2020, 12:41 PM
Adeel