Reputation: 19
When I print the range of my tuple it prints the first line and then goes through all 13 lines and keeps adding them to my tuple. This is what I want my program to do but I'm looking to just print the last tuple that has all the information in it not all of the ones which get added up...
for i in range(1,13):
tuple_list.append((line_list[i],year,header[i]))
print(tuple_list)
For example if the tuples were: [1] [1,2] [1,2,3] [1,2,3,4]
I only want to print the [1,2,3,4]
tuple not the earlier ones. Thanks
Upvotes: 0
Views: 89
Reputation: 174706
For getting the last element, you need to specify -1
as index number.
for i in range(1,13):
tuple_list.append((line_list[i],year,header[i]))
print(tuple_list[-1])
Upvotes: 1