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?9 Respostas
0
can you provide a link to the challenge itself? just to make sure i dont get the weong one.
0
One contraints is there may be any number of guards. . So i think these cases may fail..
GG$T
G$GT...
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.
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')
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â)
0
That's a good one. Thanks for the help :D
0
ur welcome; thx to The Friend. đ
0
Haha