Sep-17-2018, 07:39 AM
How can I add a $ sign to this
total_value = int ( Input (“total value of booty in dollars: ”))
total_value = int ( Input (“total value of booty in dollars: ”))
Homework help
|
Sep-17-2018, 07:39 AM
How can I add a $ sign to this
total_value = int ( Input (“total value of booty in dollars: ”))
yes and no
total_value = int ( Input (“total value of booty in dollars: ”))it would have to be a string: ptotal_value = '${}'.format(total_value)
Sep-17-2018, 01:26 PM
There is no builtin function 'Input'. It is lower case.
Sep-17-2018, 03:11 PM
(This post was last modified: Sep-17-2018, 03:11 PM by gruntfutuk.)
(Sep-17-2018, 07:39 AM)abdullahali Wrote: How can I add a $ sign to thisYou add the $ when you output the value, not when you store the numeric value. At least, that's the case if you want to user standard integers or floats. (You could create your own class that supports currency numerics including currency symbols.) Standard approach: total_value = int(input("total value of booty in dollars: ")) # expect only a number to be entered print(f'Total value: ${total_value}') # this is using f-strings
I am trying to help you, really, even if it doesn't always seem that way
Sep-17-2018, 05:19 PM
Look at locale module.
|
|