In python I can use this to check if the element in list a
:
>>> a = range(10)
>>> 5 in a
True
>>> 16 in a
False
Use the include?()
method:
(1..10).include?(5) #=>true
(1..10).include?(16) #=>false
EDIT:
(1..10)
is Range in Ruby , in the case you want an Array(list) :
(1..10).to_a #=> [1,2,3,4,5,6,7,8,9,10]