Python - How to get first item in list on list in python3 Python - How to get first item in list on list in python3 python-3.x python-3.x

Python - How to get first item in list on list in python3


You are looping over all elements of all nested lists. If you only wanted to print the first element of each nested list, use indexing:

for sublist in edge:    print(sublist[0])

If all nested lists have the same number of elements you could use unpacking:

for start, end in edge:    print(start)