0

Help me please!

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

2nd Nov 2021, 11:42 AM
G'anijonov Sarvarbek
G'anijonov Sarvarbek - avatar
6 Antworten
+ 2
s = """Some book Another book""" for ln in s.split('\n'): print(ln[0], len(ln), sep="") # or file_object = open("books.txt", 'r') for ln in file_object: print(ln[0], len(ln), sep="") file_object.close() # Keep learning & happy coding :D
2nd Nov 2021, 2:02 PM
SoloProg
SoloProg - avatar
+ 1
Ok understandable but I tried many times,(
2nd Nov 2021, 1:30 PM
G'anijonov Sarvarbek
G'anijonov Sarvarbek - avatar
+ 1
text = input() print(f'{text[0]}{len(text)}') #input: Harry Potter #output: H12
2nd Nov 2021, 5:41 PM
Fꫀⲅძ᥆͟ᥙ᥉᯽
Fꫀⲅძ᥆͟ᥙ᥉᯽ - avatar
0
G'anijonov Sarvarbek share your attempt. Then we may find what is your mistake? And corrections. . Asking and giving only * code * will not helpful. ..
2nd Nov 2021, 6:10 PM
Jayakrishna 🇮🇳
0
Ok, thanks your advice)
2nd Nov 2021, 6:41 PM
G'anijonov Sarvarbek
G'anijonov Sarvarbek - avatar
- 1
Where is your attempt? Pls try it yourself first and post your try here...
2nd Nov 2021, 1:26 PM
Jayakrishna 🇮🇳