Facebook
From Albert C Dominic , 1 Year ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 259
  1. def search_element(arr, element):
  2.     for i in range(len(arr)):
  3.         if arr[i] == element:
  4.             return i
  5.     return -1
  6.  
  7. # Example usage
  8. my_array = [10, 20, 30, 40, 50]
  9. element_to_search = 30
  10.  
  11. result = search_element(my_array, element_to_search)
  12.  
  13. if result != -1:
  14.     print(f"The element {element_to_search} is found at index {result}.")
  15. else:
  16.     print(f"The element {element_to_search} is not present in the array.")

Replies to Array search rss

Title Name Language When
Re: Array search Albert text 1 Year ago.