Write a python program that receives the index and returns the corresponding
value
Answers
Answered by
4
The python program for the above question is stated below:
Explanation:
a=[1,2,3,4,5,6,7,8,9,10]# list declaration and initialization.
print("Enter the location of 0 to 9 because the list holds only 10 value")# instruction for the user.
x=int(input()) # user location or index inputs.
print(a[x]) # print the value of the user input location.
Output:
- If the user input is 1 then the output is 2.
- If the user input is 0 then the output is 1.
Code Explanation:
- Firstly we need to initialize the list from which the user gets the value by the index.
- Then there is a print statement that instructs the user what is the highest and lowest value of the user which he needs to enter.
- Then there is an input statement which takes the index value by the user
- Then there is a print statement that prints the index value of the list.
Lean More:
- Python: https://brainly.in/question/14689905
- Python program :https://brainly.in/question/11062269
Similar questions