Guest User

Untitled

a guest
Jan 19th, 2019
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. lst1 = [('Debt collection', 5572),
  2. ('Mortgage', 4483),
  3. ('Credit reporting', 3230),
  4. ('Checking or savings account', 2068),
  5. ('Student loan', 431)]
  6.  
  7. lst2 = [('Consumer Loan', 480),
  8. ('Student loan', 1632),
  9. ('Medical loan', 1632),
  10. ('Vehicle loan or lease', 377),
  11. ('Money transfer, virtual currency, or money service', 248),
  12. ('Payday loan, title loan, or personal loan', 245),
  13. ('Prepaid card', 83)]
  14.  
  15. (non-existent tuple, 0)
  16.  
  17. lst1 = [('Debt collection', 5572),
  18. ('Mortgage', 4483),
  19. ('Credit reporting', 3230),
  20. ('Checking or savings account', 2068),
  21. ('Student loan', 431),
  22. ('Consumer Loan', 0),
  23. ('Medical Loan', 0),
  24. ('Vehicle loan or lease', 0),
  25. ('Money transfer, virtual currency, or money service', 0),
  26. ('Payday loan, title loan, or personal loan', 0),
  27. ('Prepaid card', 0)]
  28.  
  29. lst1.append((tpl[0],0) for tpl in
  30. lst1 for tpl1 in lst2 if tpl1[0] not in tpl)
  31.  
  32. [('Debt collection', 5572),
  33. ('Mortgage', 4483),
  34. ('Credit reporting', 3230),
  35. ('Checking or savings account', 2068),
  36. ('Student loan', 431),
  37. <generator object <genexpr> at 0x12bc68780>]
  38.  
  39. lst1 = [('Debt collection', 5572),
  40. ('Mortgage', 4483),
  41. ('Credit reporting', 3230),
  42. ('Checking or savings account', 2068),
  43. ('Student loan', 431)]
  44.  
  45. lst2 = [('Consumer Loan', 480),
  46. ('Student loan', 1632),
  47. ('Medical loan', 1632),
  48. ('Vehicle loan or lease', 377),
  49. ('Money transfer, virtual currency, or money service', 248),
  50. ('Payday loan, title loan, or personal loan', 245),
  51. ('Prepaid card', 83)]
  52.  
  53. available = [tpl[0] for tpl in lst1]
  54. lst1.extend(tuple((tpl1[0], 0) for tpl1 in lst2 if tpl1[0] not in available))
  55.  
  56. print(lst1)
Add Comment
Please, Sign In to add comment