+ 2

Why isn't code working

Please someone should explain to me why this code for the book titles code project in the Python core tutorial isn't working. https://code.sololearn.com/ccbKMVExDPgk/?ref=app

18th Aug 2022, 5:13 PM
DarkPhoenix15
DarkPhoenix15 - avatar
5 odpowiedzi
+ 3
DarkPhoenix15 else part print(books[k][0] + str(len(books[k].replace('\n', ''))))
18th Aug 2022, 5:30 PM
A͢J
A͢J - avatar
+ 2
DarkPhoenix15 There might be \n at the end of last character so you should remove that
18th Aug 2022, 5:20 PM
A͢J
A͢J - avatar
+ 2
AJ How?
18th Aug 2022, 5:22 PM
DarkPhoenix15
DarkPhoenix15 - avatar
+ 2
DarkPhoenix15 first replace string using replace function then get books length replace('\n', '')
18th Aug 2022, 5:28 PM
A͢J
A͢J - avatar
+ 2
Thanks but I solved it. The issue was I didn't didn't properly define the if condition
18th Aug 2022, 5:38 PM
DarkPhoenix15
DarkPhoenix15 - avatar