+ 1
Why can't I print the first letters correctly?
file = open("/usercode/files/books.txt", "r") elements = file.readlines() con_elements = len(elements) i = 0 while i < con_elements: word = elements[i] if "\n" in word: a = len(elements[i]) - 1 else: a = len(elements[i]) letters = word[i] con_word = str(a) i = i + 1 print(letters + con_word) file.close() https://code.sololearn.com/cdnBIi34989r/?ref=app
1 Resposta
+ 3
You need
letters = word[0]
Instead of
letters = word[i]