- 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
4 ответов
+ 2
where is your coding attempt?
+ 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.
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()
- 1
Илья Мирошник thank u