from typing import Union, Set, List, Tuple, Any
Vectors = Union[Tuple, List, Set]
# create this function
def lookthelast(items: Vectors) -> Tuple[Any, bool]:
lenght_items = len(items)
for index, value in enumerate(items):
if index == (lenght_items - 1):
yield value, True; break
yield value, False
# an example use case
numbers = ["one", "two", "three"]
for value, is_last in lookthelast(numbers):
if is_last:
print("this is the last element -> " + value)
break
print(value)
To embed this project on your website, copy the following code and paste it into your website's HTML: