0

I believe my function works but the challenge itself wont pass the strings as parameters.

https://www.sololearn.com/coach/77?ref=app Security Code Challenge

18th Apr 2020, 5:24 PM
Anthony Capo
Anthony Capo - avatar
4 Antworten
+ 2
You have to also call the function as: secure(input())
18th Apr 2020, 5:36 PM
Tricker
+ 1
That worked thank you !
18th Apr 2020, 5:41 PM
Anthony Capo
Anthony Capo - avatar
0
def secure(str): guard = "G" theif = "T" cash = "
quot; currentCombo = ''" alarm = False for chars in str: if chars != "x": currentCombo += chars positions = [ currentCombo.find(cash), currentCombo.find(theif) ] if ((positions[0] - positions[1]) == 1): alarm = True elif ((positions[1] - positions[0]) == 1): alarm = True if alarm == True: print("ALARM") else: print("quiet")
18th Apr 2020, 5:25 PM
Anthony Capo
Anthony Capo - avatar
0
Example : secure("xxxGxx$xxxT") Should return Alarm becuase there is no G between $ and T. G=GUARD $=CASH T=THEIF
18th Apr 2020, 5:27 PM
Anthony Capo
Anthony Capo - avatar