Advertisement
ralig

Untitled

Dec 7th, 2020
1,072
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. line = 'dotted blue bags contain 3 wavy bronze bags, 5 clear tomato bags.'
  2.  
  3.     mbag = " ".join(line.split(" ")[:2])
  4.     contains = line[line.index("contain ")+8:-1]
  5.     each_contain = contains.split(",")
  6.     each_contain = [cnt.lstrip() for cnt in each_contain]
  7.     each_contain = [" ".join(cont.split(" ")[:-1]) for cont in each_contain]
  8.     #print(each_contain)
  9.     each_contain = {" ".join(cont.split(" ")[1:]):cont.split(" ")[0] for cont in each_contain}
  10.     #print(each_contain)
  11.     if mbag not in bag_types:
  12.  
  13.  
  14. at end of this:
  15. mbag = 'dotted blue'
  16. each_contain = {'clear tomato': '5', 'wavy bronze': '3'}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement