def find_first_and_Last_position(arr, n):
first = -1
last = -1
for i in range(0, len(arr)):
if (n != arr[i]):
continue
if (first == -1):
first = i
last = i
return first, last
arr = [1, 3, 7, 8, 3, 1, 9]
n = 3
first, last = find_first_and_Last_position(arr, n)
if (first != -1):
print("First positions = ", first, " Last positions = " , last)
else:
print("Not Found")
'''
run:
First positions = 1 Last positions = 4
'''