Skip to content

Instantly share code, notes, and snippets.

@slingam00
Last active May 22, 2020 05:36
Show Gist options
  • Save slingam00/146ed1cdf6cf9741043f6151a255ea66 to your computer and use it in GitHub Desktop.
Save slingam00/146ed1cdf6cf9741043f6151a255ea66 to your computer and use it in GitHub Desktop.
myList = [1, 2, 3, 4, 5]
# Iterating through a list
for i in myList:
print(i) # The elements in myList will each get printed on a new line
for i in range(len(myList)):
print(myList[i]) # Same thing, but the elements are getting index and then printed out
# Iterating through a string
myString = "hello"
for i in myString:
print(i) # each letter printed out on a seperate line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment