samedi 20 juin 2020

I don't know why there is an error in the code. List to detect remainder of 3 and sort into other lists

Below is my code and error which I get on running :

src_list = [12,45,34,13,100,24,56,74,109]
n = 0
a_list = []
b_list = []
c_list = []
for i in range(len(src_list)):
    if src_list[n] % 3 = 0:
        a_list.append(src_list[n])
    elif src_list[n] % 3 = 1:
        b_list.append(src_list[n])
    else:
        c_list.append(src_list[n])
    n = n+1
print(a_list)
print(b_list)
print(c_list)

Error : SyntaxError:bad input on line 7

Aucun commentaire:

Enregistrer un commentaire