0

help with Book title

file = open("/usercode/files/books.txt", "r") cont = file.readlines() for i in cont: print(f'{i[0]}{len(i)-1}') file.close()

7th Apr 2021, 1:57 AM
John Delvin
John Delvin - avatar
1 Resposta
+ 6
I did in a different way file = open("/usercode/files/books.txt", "r") for line in file: if line[-1] == '\n': print(line[0] + str(len(line) -1)) else: print(line[0] + str(len(line))) #your code goes here file.close()
7th Apr 2021, 2:13 AM
Scarlet Witch
Scarlet Witch - avatar