Book Title Troubles | Sololearn: Learn to code for FREE!


Book Title Troubles

I've been trying out the book title challange in the python tutorial and I think I may be going a bit insane. When i run the code below, I get exactly the same output as Sololearn, but it's wrong. Can anybody shed some light on my mistake?

11/14/2020 11:33:49 AM


3 Answers

New Answer


Slick , it is mentioned in the task with "!" that readlines function adds a newline character "\n", so I think that's the problem. One possible solution you can see in the code. Hope it helps you.


That's going to be it, thanks NotAPythonNinja and TheWh¡teCat 🇧🇬 ! Such a silly problem sheesh


A simpler way with 5 lines of code. A simple explanation, loop through all lines, and if a line has trailing/ending "\n" remove it from the count of the length.