+ 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")3 Antworten
+ 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.