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))

10th Mar 2024, 9:19 AM
Ɲ𝚎𝚎τ ⸙
Ɲ𝚎𝚎τ ⸙ - avatar
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
15th Apr 2024, 11:39 AM
Monachopsis
Monachopsis - avatar
+ 2
you are supposed to take 4 inputs, not one input
10th Mar 2024, 11:14 AM
Lisa
Lisa - avatar
+ 1
We cannot access your code. Put your code in a script on sololearn playground and LINK your code.
10th Mar 2024, 10:31 AM
Lisa
Lisa - avatar
+ 1
Lisa here is my code for the problem "It's a Sign" https://sololearn.com/compiler-playground/cXoTVxmeOsay/?ref=app
10th Mar 2024, 11:05 AM
Ɲ𝚎𝚎τ ⸙
Ɲ𝚎𝚎τ ⸙ - avatar
+ 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
10th Mar 2024, 11:14 AM
Mihaly Nyilas
Mihaly Nyilas - avatar
0
Lisa Thankyou! Now the output is correct in all cases.
10th Mar 2024, 11:26 AM
Ɲ𝚎𝚎τ ⸙
Ɲ𝚎𝚎τ ⸙ - avatar
26th Apr 2024, 10:25 AM
Ɲ𝚎𝚎τ ⸙
Ɲ𝚎𝚎τ ⸙ - avatar