I am trying to get a sum of all elements using while loop.
from numpy import *
x = array([1, 23, 43, 72, 87, 56, 98, 33])
def sum_x(x):
sum = 0
for i in x:
sum += i
return sum
print(sum_x(x))
This is the code I made for 'for loop'. I would like to change it to 'while loop' code. Please help me out! I have no idea how to add an element to an element in while loop.