Advertisement
Guest User

Untitled

a guest
Aug 30th, 2015
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. income = ['sdjhgs', [1, 2, 4, [(1, 2), 76, 'dsg', 13],[1]], 1, 2, (12)]
  2. outcome = ['sdjhgs', 1, 2, 4, 1, 2, 76, 'dsg', 13, 1, 1, 2, 12]
  3.  
  4.  
  5. def unpack(l):
  6. '''
  7. '''
  8.  
  9. result = []
  10.  
  11. for i in l:
  12. if hasattr(i, '__iter__'):
  13. r = unpack(i)
  14. result.extend(r)
  15. else:
  16. result.append(i)
  17. return result
  18.  
  19.  
  20. result = unpack(income)
  21.  
  22.  
  23. print 'income: {}'.format(income)
  24. print 'predicted outcome: {}'.format(outcome)
  25. print 'result: {}'.format(result)
  26. print 'predicted outcome == result? {}'.format(outcome == result)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement