+ 1

Guys hu can help me out on the "Book titles project"?

Python book titles project

30th May 2021, 2:53 PM
Edward Blessing
Edward Blessing - avatar
5 Answers
+ 3
Show your attempt.
30th May 2021, 3:22 PM
AKSHAY🇼🇳
AKSHAY🇼🇳 - avatar
+ 1
Yes, Edward B. If the answer is given directly to you, you may not learn anything
30th May 2021, 3:35 PM
Quadri Lasisi
Quadri Lasisi - avatar
+ 1
Edward B. If you check the NOTE at the end of problem. There is written, every line except the last one contain a '\n' character at the end which denotes new line and it is also counted as 1 when you use "len" function. You have to do some thing like this: for i in m: if i==lines[-1]: print(i[0]+str(len(i))) else: print(i[0]+str(len(i)-1)) file.close() Hope you understood.
31st May 2021, 7:01 AM
AKSHAY🇼🇳
AKSHAY🇼🇳 - avatar
0
This project is about files and exeptions (opsionally). So you should know the functions and methods mentioned in that's module lessons. It says at attention box the readLines() method. 1- You should use it to get a list of lines in the file. 2- Then, iterate over it with a for loop. 3- During iteration, check for requirements mentioned at project. 4- Fulfill those requirements. 5- Don't forget to close the file after operating. I would like to see your attempt if you get it 😋🙂
30th May 2021, 4:57 PM
Ervis Meta
Ervis Meta - avatar
0
file = open("/usercode/files/books.txt", "r") m=file.readlines() for i in m: print(i[0]+str(int(len(i)))) file.close() #your code goes here file.close()
31st May 2021, 6:46 AM
Edward Blessing
Edward Blessing - avatar