Last active
September 27, 2017 16:19
-
-
Save AO8/c6d6c3afe9901b00535f5935b9b386a2 to your computer and use it in GitHub Desktop.
Simple practice exercise using Python's startswith() and index() methods.
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
words = ["hello", "Break", "cat", "blue", "brown", "zoo", "baby", "pie", "BOOM!"] | |
def b_count(lst): | |
# prints index and string of every element in a list that starts with the letter 'b' or 'B' | |
for i in lst: | |
if i.startswith("b") or i.startswith("B"): | |
print("Index " + str(lst.index(i)) + ": " + i) | |
b_count(words) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment