I'm very new to python but i will try to explain. I have a input like this 1234567890 and i want it to be more readable when it is a larger number and i want it to be formatted like this 1,234,567,890.
from datetime import datetime
def price_calc():
the_item = 38
amount_of_the_item = input("Amount of items: ") #This output is what i want to change.
price = ((int(amount_of_the_item)) * (int(the_item)))
print("{:,}".format(price),"USD")
now = datetime.now()
t = now.strftime("%H:%M:%S")
print("Time", t)
while True:
price_calc()
Right now I get this from the console:
Amount of items: 1234567890
46,913,579,820 USD
Time 01:22:29
But I want to get this instead:
Amount of items: 1,234,567,890
46,913,579,820 USD
Time 01:22:29
and the first line of the console output is what I want to change.
print("Amount of items: {:,}".format(amount_of_the_items))after theinputstatement to present the formatted version.inputcall itself; you can see they already use your linked solution for theUSDline, so that is not the correct duplicate.1000000and1,000,000and leaving it up to the user. But if you insist on doing all the work, this might be a good starting point: code.activestate.com/recipes/134892