After trying to solve a problem nearly for 1 hour getting error as vertex is not defined. Finally got that the ADT shows that the edges are list of numbers and not a list of Adjnode which is quite confusing. To any one trying to print edges just use the element directly instead of using element.vertex.
Course: https://www.educative.io/courses/algorithms-coding-interviews-python
Lesson: https://www.educative.io/courses/algorithms-coding-interviews-python/solution-find-all-connected-components-of-a-graph