fork download
  1. def xyz(a,n):
  2. for i in range(0,len(a)):
  3. if a[i]==n:
  4. returni
  5. return -1
  6. a=[1,2,3,4,5,6,7,8,9]
  7. n=int(input("Enter the number to search:"))
  8. r=xyz(a,n)
  9. if r!=-1:
  10. print("element found at index:",str(r))
  11. else:
  12. print("element not found")
Success #stdin #stdout 0.03s 9736KB
stdin
3
stdout
Enter the number to search:element not found