lundi 14 mai 2018

Function that appends to list of choice

I'm trying to create a function with two inputs that can append a value into a list of choice. I'm starting of with two lists to get the code working before I build up.

a = []
b = []

def func(z,x):
   if z == a:
       a.append(x)
   elif z == b:
       b.append(x)
   print(a,b)

For some reason it appends to the first list, then the second, no matter which I select. I've only just started to learn python, so I may have missed something basic.

Aucun commentaire:

Enregistrer un commentaire