def find_element(arr, x): indices = [] for i in range(len(arr)): if arr[i] == x: indices.append(i) return indices arr = [1, 2, 3, 4, 5, 3, 6, 7, 3] x = 3 result = find_element(arr, x) if len(result) > 0: print(f"The element {x} is found at index(s): {result}") else: print(f"The element {x} is not found in the array.")
Пример:
Input: arr = [1, 2, 3, 4, 5, 3, 6, 7, 3] x = 3 Output: The element 3 is found at index(s): [2, 5, 8]
sure:
def find_element(arr, x):indices = []
for i in range(len(arr)):
if arr[i] == x:
indices.append(i)
return indices
arr = [1, 2, 3, 4, 5, 3, 6, 7, 3]
x = 3
result = find_element(arr, x)
if len(result) > 0:
print(f"The element {x} is found at index(s): {result}")
else:
print(f"The element {x} is not found in the array.")
Пример:
Input:arr = [1, 2, 3, 4, 5, 3, 6, 7, 3]
x = 3
Output:
The element 3 is found at index(s): [2, 5, 8]