+ 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
6 ответов
+ 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()
+ 1
thanks hahahaha sometimes it's all in the little details
0
can you explain your code for me?
why have you added count = "" in the last line?
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
0
I did try the code without that last line but I still don't understand its functionality
0
I spend lot's of time trying to put the result on a file instead of simply print it