0

book titles project,

printing first letter of all words in a text file with characters count ex: manifest = m7 i tried but not getting the answer my code: file = open("book.txt") book=file.readlines() for i in book: print(i[0],len(i)-1) file.close()

30th Jan 2021, 6:23 PM
MALLIKHARJUNA
MALLIKHARJUNA - avatar
3 Answers
+ 2
try something like this, name = "manifest" print(name[0]+str(len(name[1:]))) name[0] gives the first letter of the word we need to count the letters except the first so we need to do this len(name[1:]) and finally we need to concat so first we need to convert int to string and done
30th Jan 2021, 6:28 PM
minirkk
minirkk - avatar
+ 1
Tnx, Got it from here
30th Jan 2021, 6:32 PM
MALLIKHARJUNA
MALLIKHARJUNA - avatar
30th Jan 2021, 6:31 PM
MALLIKHARJUNA
MALLIKHARJUNA - avatar