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?

19th Jun 2020, 5:20 PM
Benedict Ositadinma Ejelonu
Benedict Ositadinma Ejelonu - avatar
5 ответов
+ 2
Post your code
19th Jun 2020, 5:23 PM
Emanuel Maliaño
Emanuel Maliaño - avatar
+ 1
You are assuming that money will always be in the x[1] position which is wrong
19th Jun 2020, 6:04 PM
Emanuel Maliaño
Emanuel Maliaño - avatar
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,
19th Jun 2020, 5:29 PM
Benedict Ositadinma Ejelonu
Benedict Ositadinma Ejelonu - avatar
0
Try this tests $xTxGxxxxx -> ALARM xxxGxxxTG$ -> QUIET
19th Jun 2020, 5:34 PM
Emanuel Maliaño
Emanuel Maliaño - avatar
0
Emanuel Maliaño I see, i modified it to this: user=input("") user=user.replace("x","") if "TG
quot; 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
19th Jun 2020, 6:05 PM
Benedict Ositadinma Ejelonu
Benedict Ositadinma Ejelonu - avatar