30th May 2022, 8:14 AM
Mohammad Zakir
5 Réponses
+ 2
Mohammad Zakir , the code you have shown can be a bit simplified: -> we don't need to use a list as a temporary buffer, after reading we can directly do the output -> you can remove all lines that are marked with '#' file = open("/usercode/files/books.txt", "r") #Ist = [] for i in file: #Ist.append(i.rstrip("\n")) print(i[0]+str(len(i.rstrip()))) #for i in Ist: #print(i[0]+str(len(i))) file.close()
30th May 2022, 7:36 PM
Lothar
Lothar - avatar
+ 1
How about you use the search bar?
30th May 2022, 8:19 AM
Slick
Slick - avatar
0
Can't understand the book- tittle problem..... Give me easy way to solve this..
30th May 2022, 8:16 AM
Mohammad Zakir
0
Which
30th May 2022, 8:19 AM
Mohammad Zakir
0
Try this way with open("/usercode/files/books.txt", "r") as file: contents = file.readlines() for line in contents: print(line[0]+str(len(line.strip())))
30th May 2022, 10:58 AM
Christian Fare T.
Christian Fare T. - avatar