+ 1
I can't find any error in this. But I am stuck at this level(python for beginners 24.2)
purity = float(input()) if purity >= 75 and purity < 83.3: print("18k") if purity >= 83.3 and purity < 91.7: print("20k") if purity >= 91.7 and purity < 99.9: print("22k") if purity > 99.9: print("24k")
2 Answers
+ 7
A N ,
independent from the hints* of Brian, there are typos in the output string.
> the code uses lowercase 'k' instead of uppercase 'K' (read the task description). after correcting this, your code will run as expected.
* surprisingly sololearn is accepting both versions:
if purity > 99.9:
if purity >= 99.9:
+ 2
A N Check the logic when purity=99.9
Coding tip: I recommend using elifs after the first if statement. As soon as one of the conditions is true, elif will prevent unnecessarily checking the remaining conditions.