Skip to content

Instantly share code, notes, and snippets.

@2tony2
Created July 5, 2024 16:10
Show Gist options
  • Save 2tony2/09a98ec19cb5dc5dea49c8e7fb496cba to your computer and use it in GitHub Desktop.
Save 2tony2/09a98ec19cb5dc5dea49c8e7fb496cba to your computer and use it in GitHub Desktop.
my_list = [1, 2, 3]
iterator = iter(my_list)
print(next(iterator)) # Output: 1
print(next(iterator)) # Output: 2
print(next(iterator)) # Output: 3
# Calling next again will raise a StopIteration Exception
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment