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
4 ответов
+ 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')
+ 2
Bob_Li
Thank you for your answer and suggestions. I will definitely keep in mind your suggestions while Programming.
+ 1
Can you share task description here..?
+ 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