0

Can someone please help me with this code..?? Showing indentation error again n again in "cnt_c = 0" .

# Feb long challenge 2 2022 "World Chess Championship" list_sc = [] for i in range (int(input())): cnt_n = 0 cnt_c = 0 cnt_d = 0 t = int(input()) a = list(input()) for i in a: if i == "N": cnt_n += 2 elif i == "C": cnt_c += 2 elif i == "D": cnt_d += 1 carlsen_sc = (cnt_n) + cnt_d chef_sc = (cnt_c) + cnt_d if carlsen_sc > chef_sc: list_sc.append(60*t) elif carlsen_sc < chef_sc: list_sc.append(40*t) elif carlsen_sc == chef_sc: list_sc.append(55*t) for i in list_sc: print(i)

15th Feb 2022, 10:02 AM
Lakshya Mittal
Lakshya Mittal - avatar
2 odpowiedzi
+ 1
hope it helps to understand identation. Simply, it is in a block of statements, all need same amount of spaces at beginning.. https://code.sololearn.com/cT5BRIbkia21/?ref=app https://code.sololearn.com/c2Uy2e5QHYGI/?ref=app https://code.sololearn.com/czKC0e9ZHTd4/?ref=app https://code.sololearn.com/c8Tyi716A9Q7/?ref=app edit: Lakshya Mittal properly idented code: list_sc = [] for i in range (int(input())): cnt_n = 0 cnt_c = 0 cnt_d = 0 t = int(input()) a = list(input()) for i in a: if i == "N": cnt_n += 2 elif i == "C": cnt_c += 2 elif i == "D": cnt_d += 1 carlsen_sc = (cnt_n) + cnt_d chef_sc = (cnt_c) + cnt_d if carlsen_sc > chef_sc: list_sc.append(60*t) elif carlsen_sc < chef_sc: list_sc.append(40*t) elif carlsen_sc == chef_sc: list_sc.append(55*t) for i in list_sc: print(i)
15th Feb 2022, 10:07 AM
Jayakrishna 🇮🇳
0
ENS domain
28th Nov 2022, 3:44 AM
Linux JOHN
Linux JOHN - avatar