# 2288. Apply Discount to Prices  ```python= class Solution: def discountPrices(self, sentence: str, discount: int) -> str: def is_price(s): return s[0] == '$' and s[1::].isdigit() def discounted(ele, discount): factor = (100 - discount) / 100 n = int(ele[1::]) x = n * factor return '$' + '{:.2f}'.format(x) li = sentence.split() for i, ele in enumerate(li): if is_price(ele): li[i] = discounted(ele, discount) return ' '.join(li) ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up