+ 1
Can it be more optimised?
Classment of multiples https://code.sololearn.com/c3AirizByeDE/?ref=app
7 Respuestas
+ 3
You could replace lines:
if i%2 == 0 :
classment["even"].append(i)
else :
classment["odd"].append(i)
With:
if i&1:
classment["odd"].append(i)
else:
classment["even"].append(i)
+ 3
multiple = {}
for i in range(2,10):
multiple[i] = []
for j in range(0,20,i):
multiple[i].append(j)
print(multiple)
You can improve it using a list comprehension.
https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2454/
+ 3
https://code.sololearn.com/c8AaWVXMjaNd
+ 2
Thx Diego
+ 2
So beautiful code Louis and David
+ 1
Thx
+ 1
lim = 20
d = { i : list( range(0,lim,i) ) for i in range( 2,int(lim/2) )}
print(d)