lst = [1,2,3,4,5,6,7,8,9,10]
lst2 =[11,12,13,14,15,16,17,18,19,20]
def even(fn,sn):
for i in sn:
if i %2 == 0:
fn.append(i) # from this point i get this output for lst: [1,2,3,4,5,6,7,8,9,10,12,14,16,18,20]
even(lst,lst2)
print(lst)
What I am trying to do here is take lst2 even numbers add them to lst, then modifying lst into all even numbers. Keep in mind I am trying to do all this in ONE function. if anyone can help me with this, it would be greatly appreciated. my desire output for lst is [2,4,6,8,10,12,14,16,18,20]
Aucun commentaire:
Enregistrer un commentaire