0
It's a Sign
What is wrong with the two test cases I can't see them and why are they wrong. Check my code here👇 https://www.sololearn.com/coach/19?ref=app The code I made: def open_or_trash(signs): listed_signs = signs.split() result="Trash" for word in listed_signs: if word == word[::-1]: result= "Open" break return result put = input("") print(open_or_trash(put))
7 Antworten
+ 1
In Python, "for-else" is useful for search for certain specific elements. So a compact solution could be:
for word in [input() for i in range(4)]:
if word == word[::-1]:
print('Open')
break
else:
print('Trash')
https://www.sololearn.com/en/compiler-playground/cg8VaUhRH85w
+ 2
you are supposed to take 4 inputs, not one input
+ 1
We cannot access your code. Put your code in a script on sololearn playground and LINK your code.
+ 1
Lisa here is my code for the problem "It's a Sign"
https://sololearn.com/compiler-playground/cXoTVxmeOsay/?ref=app
+ 1
at me works.
for example:
input: 7
# open
input: 13
# trash
input: ababa
# open
if word == word[::-1]:
this code means, if the reversed word is the same as the original one, then give a feedback as: open.
I hope this helps
0
Lisa Thankyou! Now the output is correct in all cases.
0
Monachopsis Cool!