0

Please help me find out the tiny bug hiding in this code and suggest ways to improve it

I was running test cases, all are being passed except the third one which is locked. This is code is made to solve the "It's a sign" challenge in code coach https://code.sololearn.com/cdHsHFS7AqY7/?ref=app

16th May 2022, 12:04 PM
Shaurya Agarwal
Shaurya Agarwal - avatar
4 Answers
+ 1
Shaurya Agarwal do not print('open') inside the if statement. There might be more than one palindrome. Just count=1 is enough. do the print('Open') and print('Trash') at the end like this: if count==0: print('Trash') else: print('Open')
16th May 2022, 5:22 PM
Bob_Li
Bob_Li - avatar
+ 2
Bob_Li Thank you for your answer and suggestions. I will definitely keep in mind your suggestions while Programming.
17th May 2022, 2:24 AM
Shaurya Agarwal
Shaurya Agarwal - avatar
+ 1
Can you share task description here..?
16th May 2022, 12:08 PM
Jayakrishna 🇼🇳
+ 1
Shaurya Agarwal it is good practice to use _ for unused variables, so your for words in range(4) can be written as: for _ in range(4): also, you don't have to split and join each word to remove whitespace. You can just use: word.replace(' ', '') and there is no need to define a reverse function. just use: if word==word[::-1]: count = 1
16th May 2022, 5:35 PM
Bob_Li
Bob_Li - avatar