I have three lists. Depending on user interaction, these list may either be available or unavailable to the user, and the way I set it up was to keep track of both the list names and states through a fourth list. But I run into trouble when I try to use the string value from my fourth list to access one of my other lists.
That is, I want to add all the strings from the available lists to a master list - how should I go about this?
domesticated = ['cow', 'sheep', 'pig']
pets = ['cat', 'dog']
wildlife = ['giraffe', 'lion', 'panda']
masterList = ['domesticated', 'pets', 'wildlife'], ['off', 'on', 'on']
def currentLists():
activeList = ''
for i in range(len(masterList[0])):
if masterList[1][i] == 'on':
activeList = activeList + masterList[0][i]
return activeList
Current output:
petswildlife
Desired output:
['cat', 'dog', 'giraffe', 'lion', 'panda']
My apologies for any confusion, I'm a complete beginner with Python. Any assistance is much appreciated.