+ 1

Code coach problems [SOLVED]

Is anyone else experiencing some problems in the code coach section? The code works fine on sololearn playground but doesn't work on the code coach section

29th Dec 2019, 4:20 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
24 ответов
+ 3
ok i got it actually it is appending '\r' at the end of each string (except the last one) so that was the reason it doesnt form a palindrome after replacing '\r' with '' it works fine
29th Dec 2019, 6:36 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 4
If only 1-2 tests fails and you have tested your code in another editor, try to cut the end of the input strings. Eg. in Python try: s = input().strip() or sometimes s = input()[:-1] It worked for me.
30th Dec 2019, 8:08 AM
Prof. Dr. Zoltán Vass
+ 2
Aaah, I remember! I also had some issues there. My suspicion was that it has to do with Sololearn's input situation, or at least is something similar. Like the EOF Error we sometimes get, you know? To evade this, I used this method: for i in range(3): try: inp = input() if not inp: break except: break I don't know why it worked, only that it worked. And now that I look at it again: I wrote 3! Why did this code even pass?! So I guess you must be right - there are issues! EDIT: It even works with range(1)!!! 😱
29th Dec 2019, 5:02 PM
HonFu
HonFu - avatar
+ 2
Ha - okay, I should have thought of that, because that problem happens in other tasks as well. Good you found it. :)
29th Dec 2019, 6:49 PM
HonFu
HonFu - avatar
+ 1
There are other reports about that in this forum, but usually it turns out that there's a slight detail you may have missed. Do you want to share your attempt, have us take a look?
29th Dec 2019, 4:44 PM
HonFu
HonFu - avatar
29th Dec 2019, 4:57 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 1
Which task was that again?
29th Dec 2019, 4:58 PM
HonFu
HonFu - avatar
+ 1
copy paste input from comments which is the same as in the 1st test case here it prints open there it prints trash
29th Dec 2019, 4:59 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 1
HonFu sorry! 'It's a sign' it was
29th Dec 2019, 5:01 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 1
HonFu you type very fast😅😂 Let me check if it works
29th Dec 2019, 5:05 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 1
I have never used try catch block in python so can you explain me what is happening here
29th Dec 2019, 5:14 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 1
It's the same like in other languages: I put the input into the try block, so if there's *any* error, the except part (==catch) is executed. And that part only breaks out of the for loop. I don't even know why I had to write it.
29th Dec 2019, 5:17 PM
HonFu
HonFu - avatar
+ 1
break statement in try block breaks out of the whole for loop, right?
29th Dec 2019, 5:22 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 1
Yes. So basically, when stuff goes wrong, the loop is aborted.
29th Dec 2019, 5:24 PM
HonFu
HonFu - avatar
+ 1
except and that if statement in try block does the same thing oh man!! i am going crazy because of this
29th Dec 2019, 5:32 PM
Saurabh Tiwari
Saurabh Tiwari - avatar
+ 1
There is a problem with me that I have experience about indendation in python, but you can solve easily doing with delete and space keyboard. You delete spaces until you are on the left, and press space into right, and making sure that statements are in same line when they have to be in the same line.
29th Dec 2019, 6:21 PM
Zetra_coder
Zetra_coder - avatar
+ 1
There's the string method strip() to cut off any whitespace from the edge of a string.
31st Dec 2019, 8:55 AM
HonFu
HonFu - avatar
+ 1
There is trim() function also to remove white spaces in string
31st Dec 2019, 9:01 AM
shubham kumar
shubham kumar - avatar
+ 1
I didnt notice any problem
26th May 2020, 12:43 AM
Shola Micheal
Shola Micheal - avatar
0
because code coach runs it with different inputs and if your code in playground works with different inputs so it should work.
29th Dec 2019, 4:44 PM
c cpp