class tango: pass def printattr(wordobj,alphabet): # NOTE: you need to finish the alphabet list and include all the letters for ltr in alphabet: if hasattr(wordobj,ltr): print "For attribute",ltr,"the value is", print getattr(wordobj,ltr) dance = tango() cha = 'cha' setattr(tango,cha, 8) print tango.cha tango.cha = 9 print tango.cha a = 'a' b = 'b' c = 'c' d = 'd' e = 'e' f = 'f' g = 'g' h = 'h' i = 'i' j = 'j' lets = [a,b,c,d,e,f,g,h,i] #dance = tango() print dance dance.c = 'cat' print dance.c # get first letter of the word # find the value in lets that is == to first letter # use hasattr to see if the object already has # an attribute with that value # if so, add word to the list with that attribute # else use setattr to make the new attribute and # use the word as the list value for the attribute for temp in lets: print "temp is",temp setattr(dance,temp,[temp+'oy',1]) #print "dance.temp is",dance.temp value = getattr(dance, temp) print "the value of dance.temp is",value print print dance.b curr = j print "curr is ",curr, "to test hasattr" if hasattr(dance,curr): val = getattr(dance,curr) print val else: print "no such attribute" print "calling printattr" printattr(dance,lets) #print dance.temp