loading...

re: Daily Challenge #56 - Coffee Shop VIEW POST

FULL DISCUSSION
 

Python solution

from decimal import Decimal

def pay(amount: Decimal) -> str:
  drink = {
    2.2: 'Americano',
    2.3: 'Latte',
    2.4: 'Flat white',
    3.5: 'Filter'
  }.get(amount)

  error_message = 'Sorry, exact change only, try again tomorrow!'
  success_message = f'Here is your {drink}, have a nice day'

  return error_message if not drink else success_message

Remember, always use decimal for currency

code of conduct - report abuse