0
i can't find a bug in my code
i was attempting a security code challenge, i wrote some code and submitted i found that in three test cases i was wrong but i can't spot where i am wrong, any help will be appreciated https://code.sololearn.com/ctkEkU334Pp8/?ref=app
16 Answers
+ 5
If $ is at the beginning, or at the end, then there will be an out-of-range list index error.
š š
if lst[ind+1] == "T" or lst[ind-1]=="T":
print("ALARM")
Actually, everything is much simpler, there are only two options when there will be an ALARM ā it's $T and T$ they should be searched for.
The if not i=="x" condition will replace your three...š
+ 4
I tested with GT$ and got error "list index out of range."
+ 3
Anesensi Jonas, if you are talking about the changes that have been made to the code, then the index problem remains, you need tocarefully re-read my answer.
+ 2
Brian
i have solved that case already, still figuring out what other errors are there to make my code work
+ 2
ok thanks already solved that indexError issue
+ 2
Anesensi Jonas, you may now have a negative index and the verification sequence may be broken.
+ 1
Remove "-1" in line 39, 42 using this editing code.
It gave me output.
Use 'break' for 'if' condition in 'for' if needed.
layout = input()
lst = []
for i in layout:
if i =="G":
lst.append(i)
break
if i =="quot;:
lst.append(i)
break
if i =="T":
lst.append(i)
break
new ="".join(lst)
ind = new.find("quot;)
if lst[ind]=="T":
print("ALARM")
elif ind != len(new)-1:
if lst[ind+1] == "T":
print("ALARM")
else:
print("quiet")
+ 1
thank you all for your participation and i'm sorry for being this way
0
ok let me try
0
i already did thanks
0
I can't see the changes neither in the code or in the statement; if their are, make them, else we might misunderstand.
0
I have tried $, and the output is quiet, is it ok according to the program statement condition.
0
i forgot to save
0
First you have to explain that what will your program do.
Input :
Output:
How many situations?
0
For all inputs except G, output is quiet, Anesensi Jonas did you overdo the code.
0
i am sorry, let's just drop the question i am tired of doing it without any success, let me go and learn the basic where i found some weakness and i will solve the problem, once i my level of building logic grew