I am trying to complete a function that takes in a list of strings and prints the first letter of each string. I defined the function as firstLetter(lst)
. and defined the list as lst = ["one", "two", "longer statement"]
. However, the function doesn't seem to be reading the list as the function returns nothing. I'll leave the code I used in the relevant section. Thanks for your help.
lst = ["one", "two", "longer statement"]
def firstLetter(lst):
for item in lst:
print(item[0])
I tested the loop inside the function, it seems to work on its own, but I can't seem to feed the list through the function. I am expecting to see:
0
t
l
However, the function returns nothing.