@diegoquevedo/

elements in list

Python

No description

fork
loading
Files
  • main.py
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
a = [0,1,0,1,2,1,0,1,3,0,2,2,4,2,2,6,2,1,6,3,2]


total = 3
r0 =[]
r1 =[]
r2 =[]
r3 =[]

for item in a:
  if item not in r0 and len(r0)<total :
    r0.append(item)
  elif item not in r1 and len(r0)==total and len(r1)<total:
    r1.append(item) 
  elif item not in r2 and len(r0)==total and len(r1)==total and len(r2)<total:
    r2.append(item) 

print(r0,"\n",r1,"\n",r2,"\n",r3)