Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
py-quickstart/docs/Iteration/for-loops/example-2.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8 lines (8 sloc)
235 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example-2.py | |
# iterating iterables, a basic example of a counting loop in python 3 | |
word = 'banana' | |
count = 0 | |
for letter in word: | |
if letter is 'a': | |
count = count + 1 # count +=1 would also work here | |
print(count) |