Jan-09-2019, 03:05 PM
There are a couple ways to correct this. The first way is calling the cvor's attribute that stores the name (ime, I believe):
for movie in graf: print(movie.ime)To simplify that, you could create a function that does the same thing and use map():
def return_movie_name(movie): return movie.ime print(map(return_movie_name, graf))Or, you can add __str__() and __repr__() methods to cvor to return the movie name when the object is printed:
class cvor: __slots__ = ('ime','susjed') def __str__(self): return self.ime def __repr__(self): return self.__str__() print(graf)