Design a Python algorithm to perform a Prefix Sum operation on an array.
[1, 2, 3, 4]
def prefix_sum(arr):
result = []
s = 0
for x in arr:
    s += x
    result.append(s)
return result

arr = [1, 2, 3, 4]
prefix_sum(arr)