0
Please someone explain this code?
Why i cannot write if "basalt" in rockID as if "basalt" == rockID. https://code.sololearn.com/cG5n8ZfR4WHS/?ref=app
6 Answers
+ 3
Cyan
Did the OP change the code in the thread? I don't see "highland)" in the code ...
+ 3
Ipang I think so, it now outputs his expected output, the "Found highlands" is now printed.
+ 2
Well, you can use == instead of "in" and it should be as you are checking if it is 'quivalent' and not 'contains'.
The reason is, "highland)" has an extra parentheses at the end of the string, just remove it and use == and replace with "highland".
https://code.sololearn.com/ca20a11A11a1
+ 2
Even Dead I Am The Hero. Try my provided code and compare. Again, please look at your "highlands", it has extra bracket at the end "highlands)", that is the reason why using 'in' and '==' have different results.
+ 1
Ipang
its giving a different output on my python interpreter. It only prints "Found Basalt" and don't execute further if I use == operator instead of in like
basalt
basalt
breccia
highland
Found basalt
Basalt 2
Beeccia 1
Highland 1
Regolith 0
0
What is it exactly are you trying to do?