python - How to find the name of a list -


i want find name of list, how can in python ?

this code:

ab = "the sky blue" #in code don't know text in ab   #others lists... bannana = ["white", "red", "blue"] tomato = ["red", "shiny", "grey"] peach = ["séché", "mure", "moisi"] spicybannana = ['uigyig','iuig','iug'] #other lists...  l1 = [bannana, tomato, peach]  randomlist = randrange(0, len(l1))  in l1[randomlist]:       if in ab:       #if list name contain 'bannana':  

as per @tim_castelijns suggestion - store lists in dictionary:

other_lists = {     'bannana': ["white", "red", "blue"],     'tomato': ["red", "shiny", "grey"],     'peach': ["séché", "mure", "moisi"] }  randomlist = random.choice(['bannana', 'tomato', 'peach']) in other_lists[randomlist]:     if in ab:         if 'bannana' == randomlist:  # use 'in' substring             ... 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -