+ 1
Python for beginners 24.2
I donât know whatâs wrong with my code? purity = float(input()) if purity >= 99.9: print("24k") else: if purity >= 91.7 and purity < 99.9: print("22k") else: if purity >= 83.3 and purity < 91.7: print("20k") else: if purity >= 75.0 and purity <83.3: print("18k")
2 Answers
+ 1
If this code was placed in a code bit and then you run you get errors our output. Like that you will understand what happened wrong..
0
Chen Lyneing You can't have an "else" block without an "if".
The rule is, either if block followed by else block (or) just if block alone...
In case of multiple conditions you can go with "if-elif-[else] " block which is similar to "if-else if-[else] " in C programming language..