0

I want to call different parts from a dict depending on variable.

import fruitList

fruit = 'Banana'

if fruitList.fruit['Color'] == "Yellow":
 print "True"
else:
 print "False"

But this does not work, AttributeError: 'module' object has no attribute 'fruit'

I know i could simply do:

if fruit == "Banana":
 var = fruitList.Banana

But that is what iam trying to get away from since it becomes to static for my purposes.

user2864740
  • 60,010
  • 15
  • 145
  • 220
tsjk
  • 43
  • 1
  • 7

0 Answers0