+ 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")4 Respuestas
+ 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.
0
Try with $xxxGxxxxT
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.
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.