fork download
  1. arr = [5.2, 3.1, 7.8, 6.5, 4.3]
  2. k = 0
  3. indices = []
  4.  
  5. for i in range(len(arr) - 1):
  6. if arr[i] > arr[i + 1]:
  7. k += 1
  8. indices.append(i)
  9.  
  10. print("Indices of numbers greater than their right neighbor:", indices)
  11. print("The number K of such numbers:", k)
Success #stdin #stdout 0.02s 7072KB
stdin
Standard input is empty
stdout
('Indices of numbers greater than their right neighbor:', [0, 2, 3])
('The number K of such numbers:', 3)