help with Book title | Sololearn: Learn to code for FREE!


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()


4/7/2021 1:57:24 AM

John Delvin

1 Answer

New Answer


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()