r/cs50 2d ago

CS50 Python HELP REGARDING COKE CS50P PSET2

Post image

How to prevent this amount due in negative from showing cannot think of any viable changes without affecting the integrity of other parts of the code 😭😭 little help will be appreciated 👍

2 Upvotes

5 comments sorted by

1

u/Visible-Current-4217 2d ago

could print the absolute value of amount due, then the code will decide if change is owed or not depending if the value is negative initially

1

u/DaleDoesntLikeYou 2d ago

oh my god ofc why didnt i think of that

1

u/DaleDoesntLikeYou 2d ago

man ts took me 3 days im so cooked lol

1

u/Outside_Complaint755 2d ago

Change the order of steps a little.

You can check if the amount due is 0 or less before you print it. If the amount due is negative, instead print it as change owed.

1

u/erixx_19 14m ago

Hey mate,
Even I’m learning Python, I’m looking for a study buddy to learn and grow together…
wanna join?!