+ 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
5 Answers
+ 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.
+ 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()
+ 1
Your result for the last line is wrong, because it has no newline character. You have to scroll the results to see it
0
can you share the code. Get rid of new line if any!
0
error in last line count is 17
it also considering newline.
you need to subtract newline count.
Hope it helped!