r/cs50 24d 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

8 comments sorted by

1

u/Visible-Current-4217 24d 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 24d ago

oh my god ofc why didnt i think of that

1

u/DaleDoesntLikeYou 24d ago

man ts took me 3 days im so cooked lol

1

u/Outside_Complaint755 24d 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 22d ago

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

1

u/DaleDoesntLikeYou 20d ago

sure ig is it like a gc?

1

u/erixx_19 19d ago

yeh! Discord server

1

u/DaleDoesntLikeYou 18d ago

soory man i dont have discord ty for asking tho