0
Why is my code being dumb lol
Trying to get total price of a purchase . The cheaper input has to be 50% less . It isnât cutting the price why? print(âHow much was the first suit? â) firstSuit = int(input()) print(âhow much was the second suit? â) secondSuit = int(input()) if firstSuit >= secondSuit: secondSuit // 2 Ect it isnât dividing the second number anyone know why?
9 Respostas
+ 1
Show us the full code.
+ 1
One problem about your copy paste here is that we can't see your indentations.
Either you should copy paste your code exactly as it is with the indentations, or even better, you save it in Code Playground and directly link it here.
0
You are only calculating the value but not storing it anywhere.
secondSuit /=2 divides secondSuit and keeps that value as secondSuit.
0
HonFu i tried secondSuit = secondSuit // 2 but it jsnt working
0
That statement stores the value, but doesn't output it on the screen.
Have you used print function to show it?
0
HonFu i have the 2 varibles added in totalCost then print. im getting the actual total number the division isnt going through
0
sorry was typing on my phone that's why the code was jacked.# Suit half off sale
# Purchasing 2 suits the cheaper one is 50% off.
print("How much was the first suit? ")
firstSuit = int(input())
print("How much was the second suit? ")
secondSuit = int(input())
if firstSuit >= secondSuit:
secondSuit = secondSuit // 2
elif secondSuit >= firstSuit:
firstSuit = firstSuit // 2
totalCost = secondSuit + firstSuit
print(totalCost)
0
It seems to work.
// cuts of the decimals, if you don't want that, use / instead.
Let's say input is 3 and 5.
3 is //'ed, which is 1.5 with decimals cut off, so 1.
And 1 + 5 is 6.
(Actually the decimals aren't cut off, but the value is lowered to the next integer.)
0
HonFu i ran it without // when i enter 500 and 200 still comes up 700 not 600