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?

27th Oct 2019, 10:07 PM
Brandon Carpenter
9 ответов
+ 1
Show us the full code.
27th Oct 2019, 10:32 PM
HonFu
HonFu - avatar
+ 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.
27th Oct 2019, 10:57 PM
HonFu
HonFu - avatar
0
You are only calculating the value but not storing it anywhere. secondSuit /=2 divides secondSuit and keeps that value as secondSuit.
27th Oct 2019, 10:26 PM
HonFu
HonFu - avatar
0
HonFu i tried secondSuit = secondSuit // 2 but it jsnt working
27th Oct 2019, 10:28 PM
Brandon Carpenter
0
That statement stores the value, but doesn't output it on the screen. Have you used print function to show it?
27th Oct 2019, 10:30 PM
HonFu
HonFu - avatar
0
HonFu i have the 2 varibles added in totalCost then print. im getting the actual total number the division isnt going through
27th Oct 2019, 10:31 PM
Brandon Carpenter
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)
27th Oct 2019, 10:37 PM
Brandon Carpenter
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.)
27th Oct 2019, 10:49 PM
HonFu
HonFu - avatar
0
HonFu i ran it without // when i enter 500 and 200 still comes up 700 not 600
27th Oct 2019, 10:53 PM
Brandon Carpenter