Loading...
Loading...
Loading...
A queue of customer names is typed on one line, separated by spaces. The next line is a position, counted from 0. Print the name at that position. If the position does not exist, print Position out of range.
Position out of range.Example 1
Input
Asha Ravi Meera 1
Output
Ravi
Position 1 is the second name.
Example 2
Input
Asha Ravi 5
Output
Position out of range
Too far.
Try the problem first. Open one hint at a time.
split() makes a list of names. A list position that does not exist raises IndexError.
Read the position with int(), then index inside try.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor