Created
          March 21, 2020 23:37 
        
      - 
      
- 
        Save andriiburka/3592e4b5e13a5016d1e0151338d24adc to your computer and use it in GitHub Desktop. 
    05. Furniture
100/100
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import re | |
| data_list = [] | |
| total = 0 | |
| while True: | |
| user_input = input() | |
| if "Purchase" in user_input: | |
| break | |
| else: | |
| pattern = r">>([A-Za-z]+)<<([0-9]+\.?[0-9]+)!([0-9]+)" | |
| match = re.match(pattern, user_input) | |
| if match: | |
| for i in re.findall(pattern, user_input): | |
| thing = match.group(1) | |
| price = float(match.group(2)) * float(match.group(3)) | |
| data_list.append(thing) | |
| total += price | |
| print("Bought furniture:") | |
| [print(thing) for thing in data_list] | |
| print(f"Total money spend: {total:.2f}") | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment