Find positions

Report a typo

Write a program that reads a sequence of numbers from the first line and the number x from the second line. Then it should output all positions of x in the numerical sequence.

The position count starts from 0. In case x is not in the sequence, print the line "not found" (quotes omitted, lowercased).

Positions should be displayed in one line, in ascending order of the value.

Here is a brief outline: read the input, then create a new list for the positions and, when iterating over the list of numbers, append all the indices of the found occurrences of x to that list (e.g. you can use a counter variable to find them). Finally, join the list of indexes or print the message "not found".

Sample Input 1:

5 8 2 7 8 8 2 4
8

Sample Output 1:

1 4 5

Sample Input 2:

5 8 2 7 8 8 2 4
10

Sample Output 2:

not found
Write a program in Python 3
# put your python code here
___

Create a free account to access the full topic