Skip to content

Instantly share code, notes, and snippets.

@erikaris
Last active November 22, 2017 12:17
Show Gist options
  • Save erikaris/000a9a562ce0e412616d7ccf5587f2f9 to your computer and use it in GitHub Desktop.
Save erikaris/000a9a562ce0e412616d7ccf5587f2f9 to your computer and use it in GitHub Desktop.
mystr = "erika"
for s in mystr:
print(s, end=" ")
it = iter(mystr)
print("\n", it)
print(next(it)) # the next() function returns the next value and advances the state
print(next(it)) # the next() function returns the next value and advances the state
print(next(it)) # the next() function returns the next value and advances the state
print(next(it)) # the next() function returns the next value and advances the state
print(next(it)) # the next() function returns the next value and advances the state
print(next(it)) # next() raises StopIteration to signal that iteration is complete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment