Final answer:
To check if a value entered by the user is in a given list, you can use the 'in' operator in Python. This program prompts the user to enter a value and prints the index if it is found in the list, otherwise it prints -1.
Step-by-step explanation:
Python Program to Check if a Value is in a List
To check if a value entered by the user is in the given list, you can use the in operator in Python. Here's how you can write a program to accomplish this:
values = [54, 80, 64, 90, 27, 88, 48, 66, 30, 11, 55, 45]
# Get the value from the user
search_value = int(input('Enter a value: '))
if search_value in values:
index = values.index(search_value)
print(f'{search_value} was found at index {index}')
else:
print('-1')
Here's an example of how the program would run:Enter a value: 64
64 was found at index 2