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

2nd Feb 2021, 4:02 AM
Even Dead I Am The Hero.
Even Dead I Am The Hero. - avatar
6 Answers
+ 3
Cyan Did the OP change the code in the thread? I don't see "highland)" in the code ...
2nd Feb 2021, 1:32 PM
Ipang
+ 3
Ipang I think so, it now outputs his expected output, the "Found highlands" is now printed.
2nd Feb 2021, 2:59 PM
noteve
noteve - avatar
+ 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
2nd Feb 2021, 4:15 AM
noteve
noteve - avatar
+ 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.
2nd Feb 2021, 11:38 AM
noteve
noteve - avatar
+ 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
2nd Feb 2021, 11:03 AM
Even Dead I Am The Hero.
Even Dead I Am The Hero. - avatar
0
What is it exactly are you trying to do?
2nd Feb 2021, 4:05 AM
Ipang