+ 1

What's wrong with my code for this problem.It is showing corrct output in my python interpreter but not in sololearn.

You are in charge of security at a casino, and there is a thief who is trying to steal the casino's money! Look over the security diagrams to make sure that you always have a guard between the thief and the money! There is one money location, one thief, and any number of guards on each floor of the casino. Task: Evaluate a given floor of the casino to determine if there is a guard between the money and the thief, if there is not, you will sound an alarm. n = 'xxxGGxx$xxxxT' n = list(n) b = [] for i in n: if i != 'x': b.append(i) for i in range(len(b)): if b[i] == '

#x27;: if b[i+1] == 'T' or b[i-1] =='T': print('ALARM') else: print("quiet")

18th Dec 2021, 5:47 AM
Nalluri Sai Kiran
Nalluri Sai Kiran - avatar
4 Respostas
+ 1
I tried your code in sololearn and it gave me correct input so i cant tell whats your problem. But i can see you can get wrong output if $ is the first character in a list, as it would check [-1] position.
18th Dec 2021, 7:12 AM
Herr Rozwel
Herr Rozwel - avatar
0
Try with $xxxGxxxxT
18th Dec 2021, 7:31 AM
Nalluri Sai Kiran
Nalluri Sai Kiran - avatar
0
I love Python because it's designed with an emphasis on code readability, making it easy to learn and use. Your script extracts the relevant characters and checks whether the money and the thief are adjacent to each other. If they are, it raises an alarm, and if they are not, it remains quiet. Your code essentially works as intended and can be slightly simplified, but overall, it's fine. Speaking of casinos, I can recommend 1 euro deposit casinos in Finland. You can find a list of such platforms at https://casino358.com/minimitalletus/1-euron/. These online platforms suit my gaming preferences and meet all my requirements. It's great that Python has an active developer community and extensive documentation. This makes it easy to find support, solutions, and updates. Additionally, the abundance of websites like this one simplifies learning the language, which can be very beneficial for those who don't have direct support.
5th Nov 2023, 11:16 AM
HislopDenR
0
Hi! Your problem may be specific to the Sololearn platform, as sometimes what works in one environment may not work in another due to different versions of the interpreter or settings. I advise you to check the logic of placing guards. By the way, if you are interested in game platforms, you should pay attention to Crazy Time. There are many nice bonuses like cashback or free spins and https://crazytimecasino.app/bonuses/ offers even more information about these promotions. The platform is well organized and the bonus terms are clear and fair, making it a great option for entertainment and fun.
16th Oct 2024, 7:42 AM
Christopher Rodriguez
Christopher Rodriguez - avatar