Hello! I am trying to make a program, and one thing which I need to do is to compare if a value is identical to a set of predefined values. Below was my first instinct:
Obviously, the input isn’t being compared to x, y, or z (as I would like it to), but rather, the list itself and its contents. I suppose I could just use a lot of ()or() blocks:
That doesn’t meet what the OP was asking. They want to do identical checks, meaning lowercase a does not equal uppercase A. The contains block doesn’t care about cases, so it will say that a = A. There’s more to the identical check though, as it’s not just doing case sensitive checks, so you can’t just turn on case sensitivity.
Thanks for the help. I think that @bh’s solution makes the most sense, but, funnily enough, @theaysnap’s solution with the ()contains() block is the most logical for me as I actually do want it to be case-insensitive (though I did not mention that in the post). If anyone was wondering, I was trying to make a script that detects whether the first letter of a word is a vowel and making the word before it a ‘a’ or an ‘an’, depending on the output (I am aware it will be occasionally incorrect, like for the word “user”, which should be ‘a’ but will be ‘an’ in my program).
Most programming languages allow you to compare strings and other data types, so it wasn’t derived from scratch, it was derived from every other programming language.