Skip to content

Instantly share code, notes, and snippets.

@aniruddha27
Created May 16, 2020 20:20
Show Gist options
  • Save aniruddha27/930998815e647657c75294a9b392762a to your computer and use it in GitHub Desktop.
Save aniruddha27/930998815e647657c75294a9b392762a to your computer and use it in GitHub Desktop.
sample = ['statistics', 'linear algebra', 'probability']
it = iter(sample)
while True:
# this will execute till an error is raised
try:
val = next(it)
# when we reach end of the list, error is raised and we break out of the loop
except StopIteration:
break
print(val)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment