'How do I get WMA if index size is greater than window size?

Is there a way to find the average of numbers if the window size is less than the index?

numbers = [1, 2, 3]
window_size = 4
i = 0
moving_averages = []
while i < len(numbers) - window_size + 1:
    this_window = numbers[i : i + window_size]

    window_average = sum(this_window) / window_size
    moving_averages.append(window_average)
    i += 1

print(moving_averages)
###returns []


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source