0
A single Test Case Failed for a logical solution and i can't view it.
https://www.sololearn.com/coach/77?ref=app Logically this is my solution to the Security problem on Code Coach, If there's a 'G' always between '
#x27; and 'T' after all the 'x's have been removed then there's no need to sound the alarm, This is quite logical, but after running the code, there's a test case that fails(only one though) and i can't see it. Why's that please? and can anyone give a better solution i might have overlooked?5 Answers
+ 2
Post your code
+ 1
You are assuming that money will always be in the x[1] position which is wrong
0
Emanuel Maliaño
Here:
x=input("") #select user input
x=x.replace("x","") #replace all ocurrences of x with empty string
if x[1]=="G": #after removing all x's, we are left with 3 string characters , if the middle string is G
print("quiet") #then print "quiet"
else:
print("ALARM") #else print Alarm,
0
Try this tests
$xTxGxxxxx -> ALARM
xxxGxxxTG$ -> QUIET
0
Emanuel Maliaño
I see, i modified it to this:
user=input("")
user=user.replace("x","")
if "TGquot; in user:
print("quiet")
elif "$GT" in user:
print("quiet")
else:
print("ALARM")
But now a "different" test case (test case 6) is evaluating to Failed, but with the previous logic it was correct