Hello. Who can help me. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 2

Hello. Who can help me.

You have been asked to make a special book categorization program, which assigns each book a special code based on its title. The code is equal to the first letter of the book, followed by the number of characters in the title. For example, for the book "Harry Potter", the code would be: H12, as it contains 12 characters (including the space). You are provided a books.txt file, which includes the book titles, each one written on a separate line. Read the title one by one and output the code for each book on a separate line. For example, if the books.txt file contains: Some book Another book Your program should output: S9 A12

15th Mar 2021, 7:18 PM
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ - avatar
4 Answers
+ 2
where is your coding attempt?
15th Mar 2021, 7:23 PM
visph
visph - avatar
+ 2
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ See my post in your other thread. Please, then attempt to solve it with your own code and if you continue to have issues post your code so we may help you further.
15th Mar 2021, 7:25 PM
ChaoticDawg
ChaoticDawg - avatar
0
Just replace \n on empty. file = open("/usercode/files/books.txt", "r") #введите код сюда d = file.readlines() for l in d: print(l[0].upper()+str(len(l.replace("\n","")))) file.close()
15th Mar 2021, 7:24 PM
Илья Мирошник
Илья Мирошник - avatar
15th Mar 2021, 7:28 PM
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ - avatar