Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- line = 'dotted blue bags contain 3 wavy bronze bags, 5 clear tomato bags.'
- mbag = " ".join(line.split(" ")[:2])
- contains = line[line.index("contain ")+8:-1]
- each_contain = contains.split(",")
- each_contain = [cnt.lstrip() for cnt in each_contain]
- each_contain = [" ".join(cont.split(" ")[:-1]) for cont in each_contain]
- #print(each_contain)
- each_contain = {" ".join(cont.split(" ")[1:]):cont.split(" ")[0] for cont in each_contain}
- #print(each_contain)
- if mbag not in bag_types:
- at end of this:
- mbag = 'dotted blue'
- each_contain = {'clear tomato': '5', 'wavy bronze': '3'}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement