'Animations in python using celluloid

I was trying the first simple animation from this page. I am clearly a beginner at making animations. I paste the code below.

from matplotlib import pyplot as plt
from celluloid import Camera

fig = plt.figure()
camera = Camera(fig)
for i in range(10):
    plt.plot([i] * 10)
    camera.snap()
animation = camera.animate()

It gives me the following error.

Animation was deleted without rendering anything. This is most likely unintended. To prevent deletion, assign the Animation to a variable that exists for as long as you need the Animation.

As far as I can see, animate() has already been assigned a name. Could anyone resolve this issue for me?



Sources

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

Source: Stack Overflow

Solution Source