0

can any one solve

Book Titles 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

29th Mar 2021, 11:19 AM
Venkatesh
Venkatesh - avatar
4 Answers
+ 5
Please post your attempt here too...
29th Mar 2021, 11:23 AM
Scarlet Witch
Scarlet Witch - avatar
+ 3
Post your attempt
29th Mar 2021, 12:06 PM
Papa Penguin
+ 2
Seems to be your homework. Anyways post what you have tried so far
29th Mar 2021, 11:32 AM
Atul [Inactive]
+ 1
#I find very difficult to solve but #finally solved it file = open("/usercode/files/books.txt", "r") for i in file.readlines(): print(i[0]+str(len(i.strip('\n')))) #your code goes here file.close() read the question properly they asked to to use file. readline() they asked to print first character only so I used i[0] and strip function here is used to remove /n here
6th Sep 2021, 11:48 AM
Nishant Kumar