Skip to content
Advertisement

The method doesn’t want to enter in for loo

JavaScript

What’s the problem with this damn loop? I don’t understand why the method doesn’t acces the loop. I tried to make videos a list because cursor type can’t be parsed. If I’m running this for loop alone, without the if statement above, it works.

JavaScript

Advertisement

Answer

videos is an iterable, and you can only iterate over it once. You exhaust it when you do if len(list(videos)) > 1:, so there’s nothing left when you try to do for video in list(videos):.

The solution is to put the list in a variable.

JavaScript

Also, you should test len > 0. There’s no problem with calculating the average of 1 video.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement