+ 2

(SOLVED)Why doesn't my final line work?

cominput = input("give sale amount in whole dollars") if cominput <= "5000": print("0.05) elif cominput > "5000" != "10000": print("0.1") else: print("0.15") (Note: i have also tried replacing the final line with elif cominput >= 10000 and that didn't work either)

8th Dec 2020, 2:28 PM
Eric
12 ответов
8th Dec 2020, 2:44 PM
noteve
noteve - avatar
+ 4
Because in the first condition you forgot to add a "
8th Dec 2020, 2:30 PM
⚡🔥 😎 Baby Hater 🔥⚡
⚡🔥 😎 Baby Hater 🔥⚡ - avatar
+ 2
Yeah ⚡🔥 😎 Baby Hater 🔥⚡ is right and also I think that final line youre talking about should be like this elif cominput > "5000" and cominput < "10000":
8th Dec 2020, 2:32 PM
noteve
noteve - avatar
+ 1
Ohh actually I noticed something wrong Its better if you convert the input first to INTEGER then Compare it to another integer.
8th Dec 2020, 2:43 PM
noteve
noteve - avatar
+ 1
thanks nicko!
8th Dec 2020, 2:47 PM
Eric
8th Dec 2020, 2:48 PM
noteve
noteve - avatar
0
What do you mean?
8th Dec 2020, 2:30 PM
Eric
0
if you are referring to the 10000 in the alternative, it was there when i tried i just forgot to type that part out when typing my question
8th Dec 2020, 2:31 PM
Eric
0
Eric In the print time of the first condition
8th Dec 2020, 2:32 PM
⚡🔥 😎 Baby Hater 🔥⚡
⚡🔥 😎 Baby Hater 🔥⚡ - avatar
0
let me just type in exactly what i have right now cominput = input("give sale amount in whole dollars ") if cominput <= "5000": print("0.05") elif cominput > "5000" and cominput < "10000": print("0.1") elif cominput >= "10000": print("0.15")
8th Dec 2020, 2:42 PM
Eric
0
How would I do that?
8th Dec 2020, 2:43 PM
Eric
0
You do realise your comparing string...eg print("6000" < "50000000") this output false.
8th Dec 2020, 2:44 PM
rodwynnejones
rodwynnejones - avatar