D
D
Dmitry Dmitriev2020-06-22 14:48:10
Python
Dmitry Dmitriev, 2020-06-22 14:48:10

How to separate rubles from kopecks?

5ef09a4ba5d06476017458.png5ef09a5fb3e73769240245.png

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
Sergey Pankov, 2020-06-22
@DmitryDmitriev

price = input()
r, c = (list(map(int, price.split('.'))) + [0])[:2]

and regexps are really useless here. At least not for such simple cases.

G
Guerro69, 2020-06-22
@Guerro69

import re
price = input('Цена: ')
a = re.findall(r"\d+\.", price)[0]
b = re.sub(f"{a}", '', price)
a = re.sub(r'\.', '', a)
print(f"{a}\n{b}")

A
antonwx, 2020-06-22
@antonwx

What's the problem?
You have done everything right. Though not optimal.
Multiply pennies by 100.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question