Using python 2.6.6,
I'm trying to use an IF statement that checks for the name of a list in a nested for loop.
This is my code:
blueList = ["light blue", "dark blue"]
redList = ["light red", "dark red"]
orangeList = ["light orange", "dark orange"]
colorsGroup = [blueList, redList, orangeList]
for member in colorsGroup:
for colorNameInList in member:
if "orange" in member.__name__:
print("the name of this list contains the word orange")
elif "red" in member.__name__:
print("the name of this list contains the word red")
elif "orange" in member.__name__:
print("the name of this list contains the word orange")
I keep getting:
AttributeError: 'list' object has no attribute '__name__'
What can I use that would allow me to check against the name of a list if that attribute doesn't exist?
Aucun commentaire:
Enregistrer un commentaire