Question: Here is an unaccomplished Python code, and i want you to fix it so that the Sample Runs can be Satisfied and match exactly with
Here is an unaccomplished Python code, and i want you to fix it so that the Sample Runs can be Satisfied and match exactly with the outputs when inserted a certain input.
def validatebudgetbudgetinput:
currencysymbols $ # Add currency symbols here
if lenbudgetinput or not budgetinput:isdigit or budgetinput not in currencysymbols:
printBudget must be an integer number followed by a currency symbol"
exit
return floatbudgetinput: budgetinput
def main:
# Get budget
budgetinput inputEnter your budget:
budget, budgetcurrency validatebudgetbudgetinput
totalcost
items
differentcurrency False
# Get grocery items and prices
while True:
iteminput inputEnter the name of the item or type 'done' to finish:
if iteminput.lower 'done':
break
itemname, itemdetails iteminput.split:
itemprice, itemcurrency floatitemdetails: itemdetails
if itemcurrency budgetcurrency:
differentcurrency True
printfItem itemname has different currency: itemcurrency
continue
if itemname in items:
printfItem itemname already exists!"
else:
itemsitemname itemprice
totalcost itemprice
# Check if total cost exceeds budget
if totalcost budget:
overage totalcost budget
printfTotal cost exceeds your budget by overage:fbudgetcurrency
elif differentcurrency:
pass
else:
remainingbudget budget totalcost
printfYou have remainingbudget:fbudgetcurrency remaining in your budget."
if namemain:
main
You can see the Sample runs in the following picture, and there are some correct and some incorrect Sample runs. In the incorrect Sample Runs, the highlighted words are selected in which it shows the difference between the "Expected" code and the "Got" code. The main objective here is to make the Sample runs all satisfied by making the "Got" code exactly equal to the "Expected" code. BEFORE SUMBMITING MAKE SURE TO TEST THEM ALL AND SEE THAT THEY ARE OUTPUTING THE SAME EXACT AS THE EXPECTED.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
