Question: INTRO TO PYTHON PROBLEM, FORMAT NUMBERS US DOLLARS I have tried for so long to get this to pass and it just won't. I left

 INTRO TO PYTHON PROBLEM, FORMAT NUMBERS US DOLLARS I have tried

INTRO TO PYTHON PROBLEM, FORMAT NUMBERS US DOLLARS

I have tried for so long to get this to pass and it just won't. I left my notes above the def in the first block, if that helps. The second block is the parameters or test or whatever its called. I can't even remember now.

20. Format a number for US dollars There are definitely ways to do this using formatting functions that are included with Python and some third-party libraries. The point of this exercise is to use what you have learn and apply it to this problem. Make sure you try to solve it yourself. 1 2 3 4 # create a new variable to hold the new string # build up the string one character at a time # str(number) [::-1] turn number into string and slice in reverse/ reverses the string # have a counter to keep track of the groups of 3 # his solution is 9 or 10 lines of code # why loop? def pretty_format_usd(number): 5 6 7 8 [] 1 2 # # DO NOT EDIT THIS BLOCK 23 3 4 5 6 7 expected = "$42" observed = pretty_format_usd(42) assert observed == expected, f" You returned: {observed!r} instead of: {expected!r}" 8 9 10 expected = "$6,543" observed - pretty_format_usd( 6543) assert observed == expected, f" You returned: 11 {observed!r} instead of: {expected!r}" 12 13 14 15 expected = "$ 14,780,371,750" observed - pretty_format_usd(14780371750) assert observed == expected, f" You returned: (observed!r} instead of: {expected!r}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!