The program that should ask the user to enter a value, If the value is in the
array, the program should print the index, If it is not in the array, the
program should print -1 is as follows:
v = [24, 20, 29, 32, 34, 29, 49, 46, 39, 23, 42, 24, 38]
x = int(input("search for: "))
for i in v:
if i == x:
print(v.index(x))
break
if x not in v:
print(-1)
The code is written in python.
The variable v is used to store an array of integers.
The variable x is used to store the user integers input
Then we loop through the array and check if the user input is equals to any value in the array.
If its equal, we print the index of the value as required.
Then we break the block.
Now another block is defined. If the user inputs is not in v(array) we print - 1.
learn more on python here: https://brainly.com/question/22316964?referrer=searchResults