+ 3

App showing incorrect data

This app is showing incorrect data for Book Titles Problem Expected output and my output are same but still getting erro

24th Nov 2020, 2:34 PM
shashank kashyap
shashank kashyap - avatar
5 Respuestas
+ 3
shashank kashyap , your solution does not show the correct answer. By reading the last line from the file, there is no new-line sequence as in the previous lines to read. so the result is 17 insted#ad of 18. What you can do is to remove all the trailing new-line sequences from the string you get from the file. This can be done with .strip(), which removes all whitespaces (new-line sequence is seen as a whitespace) from the beginning and the end of the line.
24th Nov 2020, 3:52 PM
Lothar
Lothar - avatar
+ 2
file = open("/usercode/files/books.txt", "r") #line= file.readliness() for i in file: print(i[0]+str(len(i)-1)) #your code goes here file.close()
24th Nov 2020, 2:47 PM
shashank kashyap
shashank kashyap - avatar
+ 1
Your result for the last line is wrong, because it has no newline character. You have to scroll the results to see it
24th Nov 2020, 2:53 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
0
can you share the code. Get rid of new line if any!
24th Nov 2020, 2:45 PM
Ashok Acharya
Ashok Acharya - avatar
0
error in last line count is 17 it also considering newline. you need to subtract newline count. Hope it helped!
24th Nov 2020, 2:53 PM
Ashok Acharya
Ashok Acharya - avatar