I understand that "in" is a reserved keyword in the Solidity language (for now) but can it be used like the "in" keyword is used in the Python language? That is can it be used to find a specific value from a range of value like from a list?

To be clear, the usage I am talking about (in Python) has been explained here. I want to know if there is a similar keyword in Solidity >0.6.0 ?

I would like to put forward a basic example :

If I create a list of some arbitrary numbers and want to find if the number 5 is present in that array, is there some simple keyword like "in" such that I write "5 in list" and get a boolean result as true/false.

Even if it is not there can you please guide me to the simple most way to do something like above?


'in' is a Reserved Keyword. This keyword are reserved in Solidity. They might become part of the syntax in the future.Check this link

But you can loop through an array/list in different way. Compared to python.

address[] public arraylist; // Creating a list of '**address**' type

arraylist.push(newAddress); //Adding elements to array.


// Length of array is known to us

uint arrayLength = arraylist.length;
for (uint i=0; i<arrayLength; i++) {
  // do anything

Hope this answers your question.

Not the answer you're looking for? Browse other questions tagged or ask your own question.