Skip to content

Instantly share code, notes, and snippets.

@andriiburka
Created March 21, 2020 23:37
Show Gist options
  • Save andriiburka/3592e4b5e13a5016d1e0151338d24adc to your computer and use it in GitHub Desktop.
Save andriiburka/3592e4b5e13a5016d1e0151338d24adc to your computer and use it in GitHub Desktop.
05. Furniture 100/100
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