Python 3 In Visual Studio
Hi there I am a newbie to Python, could someone help me how to convert an input string to ZAR (South African Rand) in order to produce the R symbol before the float amount the user
Solution 1:
There is no special format for currency in standard library. You can organize output formatting like that:
zar = float(input("ZAR="))
print('R{:.2f}'.format(zar))
but in finance calculations better use Decimal
not float
.
Or - create own class ZAR() with special method __str__()
if You really need it )
Post a Comment for "Python 3 In Visual Studio"