Basically I want to find and print the positions of all the duplicate elements. Here is my code:
numbers = [7,1,3,6,4,2,5,9,8,10]
n = int(input("Enter a number from 1 to 10 to search for the number's position: "))
def findNum():
count = 0
while numbers[count] != n:
count += 1
numPos = count + 1
print(numPos)
if n in numbers:
print("Calculating position... (takes 9 years so wait)")
findNum()
else:
print("Number not found, next time enter a number from 1 to 10!")
For example I add an extra 7
to numbers
:
numbers = [7,1,3,6,4,2,5,9,8,10,7]
Then I want to return the 1st 7
's position and also the other 7
's position. How to do it?