Created
October 19, 2021 03:48
-
-
Save Pinacolada64/7f9522f69914e66dcea724f54e924346 to your computer and use it in GitHub Desktop.
Print a list of items in a grammatically correct way
This file contains hidden or 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
def grammatical_list(item_list): | |
print("Entered function") | |
for item in item_list: | |
if item[:-1] == 's': | |
item = "some " + item | |
if item.startswith(('a', 'e', 'i', 'o', 'u')): | |
item = "an " + item | |
# print(item, sep="and, ", end='') | |
print(item) | |
print("Exited function") | |
if __name__ == '__main__': | |
# should print "You see some bells, an apple, and a candle": | |
grammatical_list(["bells", 'apple', 'candle']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Try: