i can't find a bug in my code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
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

18th Oct 2023, 4:20 PM
Anesensi Jonas
Anesensi Jonas - avatar
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...😎
18th Oct 2023, 4:49 PM
Solo
Solo - avatar
+ 4
I tested with GT$ and got error "list index out of range."
18th Oct 2023, 4:33 PM
Brian
Brian - avatar
+ 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.
18th Oct 2023, 5:12 PM
Solo
Solo - avatar
+ 2
Brian i have solved that case already, still figuring out what other errors are there to make my code work
18th Oct 2023, 4:45 PM
Anesensi Jonas
Anesensi Jonas - avatar
+ 2
ok thanks already solved that indexError issue
18th Oct 2023, 4:51 PM
Anesensi Jonas
Anesensi Jonas - avatar
+ 2
Anesensi Jonas, you may now have a negative index and the verification sequence may be broken.
18th Oct 2023, 6:06 PM
Solo
Solo - avatar
+ 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")
19th Oct 2023, 8:34 AM
Shashank Reddy Voorelli
Shashank Reddy Voorelli - avatar
+ 1
thank you all for your participation and i'm sorry for being this way
20th Oct 2023, 7:11 PM
Anesensi Jonas
Anesensi Jonas - avatar
0
ok let me try
18th Oct 2023, 5:38 PM
Anesensi Jonas
Anesensi Jonas - avatar
0
i already did thanks
19th Oct 2023, 11:05 AM
Anesensi Jonas
Anesensi Jonas - avatar
0
I can't see the changes neither in the code or in the statement; if their are, make them, else we might misunderstand.
19th Oct 2023, 11:30 AM
Shashank Reddy Voorelli
Shashank Reddy Voorelli - avatar
0
I have tried $, and the output is quiet, is it ok according to the program statement condition.
19th Oct 2023, 11:34 AM
Shashank Reddy Voorelli
Shashank Reddy Voorelli - avatar
0
i forgot to save
20th Oct 2023, 3:52 AM
Anesensi Jonas
Anesensi Jonas - avatar
0
First you have to explain that what will your program do. Input : Output: How many situations?
20th Oct 2023, 4:20 PM
Dipankar Priyadarshi
Dipankar Priyadarshi - avatar
0
For all inputs except G, output is quiet, Anesensi Jonas did you overdo the code.
20th Oct 2023, 4:54 PM
Shashank Reddy Voorelli
Shashank Reddy Voorelli - avatar
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
20th Oct 2023, 7:10 PM
Anesensi Jonas
Anesensi Jonas - avatar