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
6 Respuestas
+ 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
+ 1
Ok understandable but I tried many times,(
+ 1
text = input()
print(f'{text[0]}{len(text)}')
#input: Harry Potter
#output: H12
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. ..
0
Ok, thanks your advice)
- 1
Where is your attempt?
Pls try it yourself first and post your try here...