how to fix error: object of type 'generator' has no len() -python

-4 python networking cluster-analysis

I just want to do the community detection using Girvan Newman Algorithm, and the code was learned from a youtube video. However, when I run the same code, there comes an error

I have tried on Mac OS X python 2.7 terminal and python 3.7 by Jupyter both and the error are the same.

我申请的代码

I expect the output to have two communities lists

Aka*_*ph7 8

You can convert to a list first to get the len:

l = len(list(c))
Run Code Online (Sandbox Code Playgroud)