Here is the purity chart we’ll be using: 24K – 99.9% 22K – 91.7% 20K – 83.3% 18K – 75.0% | Sololearn: Learn to code for FREE!


Here is the purity chart we’ll be using: 24K – 99.9% 22K – 91.7% 20K – 83.3% 18K – 75.0%

If the percentage is between 75 and 83.3, the gold is considered to be 18K. If it's between 83.3 and 91.7 - then it’s 20K, and so on. Given the percentage as input, output the corresponding Karat value, including the letter K. Here is my code, but unfortunately its not working. purity = float(input()) if purity >= 99.9: print('24k') elif purity >= 91.7: print('22k') elif purity >= 83.3: print('20k') elif purity >= 75: print('18k')

6/23/2021 7:10:45 PM

Sanchit Bahl

7 Answers

New Answer


just remember python is case sensitive language... You're welcome....


visph I agree... Language case sensitivity would apply to things like variable and function names or class names, etc. However, here, case sensitivity applies to string character comparisons. These are fundamentally different concepts.


All you need Capital K in 24K, 22K .. instead of small k.


Thats exactly what happens, when a commerce student start learning a computer language from the scratch 😜. Anyways thanks for your help man !


Sanchit Bahl What's a "commerce student"?


visph yes. that's not a noticeable mistake using of "small k" in string. But after op reply I guess he/she is new to coding and also may came here after knowing html. That's my guess that time so I added case sensitivity info. So next time he care about it similar cases of strings, by himself... output is user defined but there it's is problem description defined. Is not it? also it was additional information some what related ...


Jayakrishna🇮🇳 is right when he said "python is case sensitive language"... however, that's not related with the problem here: upper/lower case mistake happen inside string... and so in output... unfortunatly, test check for exact output (case sensitive), rather than checking for output without matter if upper/lower case: here the case sensitivity is not related with the language case sensitivity ^^