function search()
array = [1,2,3,4,5]
low = 0
high = 0
while true
print("Please enter two numbers for Low and high index: ")
low, high = parse.(Int, split(readline()))
if (low <=0) || (high > length(array))
println("Wrong range.")
else
break
end
end
print("Please enter a number to check if it exists: ")
n = parse.(Int, readline())
flag = 0
for i = low : high
if n == array[i]
println("Exist.")
break
else
flag += 1
end
end
if flag > 0
println("Doesn't exist.")
end
end
search()
Mh, there is the potential edge case of an empty range, such as low = 2, high = 1, n = 10. Here your code doesn’t print anything, whereas you might either add a check low < high or print Doesn't exists.