0
Why my code does not work?
In the 5th module of Python core course there is a problem about books. Here is my code: https://code.sololearn.com/c75Ez66ZgRRG/?ref=app
2 Answers
+ 3
by reading lines, you've got the end of line char ("\n") at end of each lines... but the last (if there's no empty lines at end of file)... so len() doesn't report the correct number of chars ^^
the simple to get lines without that unexpected char would be to apply .trim() merhod to string before using it as len() argument:
len(i.trim())
+ 1
Thank you very much!