Python Forum
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Homework help
#1
How can I add a $ sign to this
total_value = int ( Input (“total value of booty in dollars: ”))
Reply
#2
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)
Reply
#3
There is no builtin function 'Input'. It is lower case.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#4
(Sep-17-2018, 07:39 AM)abdullahali Wrote: How can I add a $ sign to this
total_value = int ( Input (“total value of booty in dollars: ”))
You 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
Reply
#5
Look at locale module.
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020