Homework help - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Homework (https://python-forum.io/forum-9.html) +--- Thread: Homework help (/thread-12872.html) |
Homework help - abdullahali - Sep-17-2018 How can I add a $ sign to this total_value = int ( Input (“total value of booty in dollars: ”)) RE: Homework help - Larz60+ - Sep-17-2018 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) RE: Homework help - wavic - Sep-17-2018 There is no builtin function 'Input'. It is lower case. RE: Homework help - gruntfutuk - Sep-17-2018 (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 RE: Homework help - wavic - Sep-17-2018 Look at locale module. |