0

Security challenge Test case #4 isn't passing

userInput = input() list = [] for char in userInput: if char == "G" or char == "

quot; or char == "T": list.append(char) if list == ['G','
#x27;,'T'] or list == ['T','
#x27;,'G'] or list == ['
#x27;,'T','G'] or list == ['G','T','
#x27;] or list == ['
#x27;,'T'] or list == ['T','
#x27;]: print("ALARM") else: print("quiet") All the tests are passing except one of them. Any help?

12th Mar 2021, 1:21 AM
Ghassan Al Khoury
Ghassan Al Khoury - avatar
9 Respostas
0
can you provide a link to the challenge itself? just to make sure i dont get the weong one.
12th Mar 2021, 4:19 AM
Wilbur Jaywright
Wilbur Jaywright - avatar
12th Mar 2021, 7:37 AM
Ghassan Al Khoury
Ghassan Al Khoury - avatar
0
One contraints is there may be any number of guards. . So i think these cases may fail.. GG$T G$GT...
12th Mar 2021, 11:46 AM
Jayakrishna 🇼🇳
0
ok, thx. In short, your existing code has what im calling dictionary logic for lack of a better term. basically, have an if statement for every possible scenario. this type of programming is very fragile as you have seen. you need to get closer to how you would solve the problem in real life. One hint i’ll give you is that once floor space is removed from the string (which can be done with the “abc”.replace() method much easier), you need not check that there is a guard in some involvement, but rather just check that the thief and the money are not next to eachother.
12th Mar 2021, 1:50 PM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
Wilbur Jaywright I finally solved this challenge after many tries. This is the way I did it, unfortunately I know it's not the best way. userInput = input() list = [] for char in userInput: if char == "G" or char == "
quot; or char == "T": list.append(char) str = "".join(list) if 'GT
#x27; in str or 'G$T' in str or '$TG' in str or 'T$G' in str: print('ALARM') else: print('quiet')
14th Mar 2021, 2:50 AM
Ghassan Al Khoury
Ghassan Al Khoury - avatar
0
oh, good. well since you’ve solved it, I might as well give you the answer i was Given by A Friend. map=input() map=map.replace(“x”, “”) if “$T” in map or “T$” in map: print(“ALARM”) else: print(“quiet”)
14th Mar 2021, 2:57 AM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
That's a good one. Thanks for the help :D
14th Mar 2021, 3:00 AM
Ghassan Al Khoury
Ghassan Al Khoury - avatar
0
ur welcome; thx to The Friend. 😊
14th Mar 2021, 3:00 AM
Wilbur Jaywright
Wilbur Jaywright - avatar
0
Haha
14th Mar 2021, 3:04 AM
Ghassan Al Khoury
Ghassan Al Khoury - avatar