![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Jedzkie |
How can I code something like this?
If my money reaches 1,000,000,000 which is 1 billion it will reset the digits to 1 and add a letter B on the side. after that, if the money reaches 1,000 Billion, instead of adding the 4th digit, it will reset again to 1 digit and change the word to trillion.
You want to separate value (number) and visualisation (label). So have money stored in a numeric variable, which you can Increment when needed and in label part, that you show to user. In label part, you can have multiple conditional statements.
var billion = 10000000000
var trillion = billion*1000
if int(money / trillion) > 0:
label = str(int(money / trillion)) + "T"
elif int(money / billion) > 0:
label = str(int(money / billion)) + "B"
else:
label = str(money)
gmaps | 2019-09-10 07:05