+ 1

Help me with the Title Encoder problem from python intermediate course[SOLVED]

I do not know why it is wrong, the code is fine and gives the output that the problem asks for, but it still tells me that it is wrong https://code.sololearn.com/cCjPv1rQ0m24/?ref=app

5th Apr 2021, 4:52 AM
luis morales
luis morales - avatar
6 odpowiedzi
+ 6
Remove your first space from each and every line of your output. Be aware that the test results need to be EXACTLY the same as your output. A single character is enough to fail and you have a character extra in each and every line. Here is a fixed version: file = open("/usercode/files/books.txt", "r") count = "" # changed to empty string. for line in file: t = line.split() for char in t: count += char[0] print (count) count = "" # should be empty string. file.close()
5th Apr 2021, 5:03 AM
Josh Greig
Josh Greig - avatar
+ 1
thanks hahahaha sometimes it's all in the little details
5th Apr 2021, 5:10 AM
luis morales
luis morales - avatar
0
can you explain your code for me? why have you added count = "" in the last line?
3rd May 2021, 5:40 PM
Hossein Karbalaei
0
H.K. remove the line, run the code, and see what happens. That should clear up the reason better than any words. Here is the output without that line: HP HPTHG HPTHGPaP HPTHGPaPGwtW See how different that is from? HP THG PaP GwtW
3rd May 2021, 5:48 PM
Josh Greig
Josh Greig - avatar
0
I did try the code without that last line but I still don't understand its functionality
3rd May 2021, 11:56 PM
Hossein Karbalaei
0
I spend lot's of time trying to put the result on a file instead of simply print it
14th Jun 2021, 12:59 PM
Nodé-Langlois Math
Nodé-Langlois Math - avatar