I am new to python.I want to know how to count the number of words starting with a particular letter say 'L' from a text file.
1 Answer
str.startswith(prefix[, start[, end]])
Give this a shot but import your file there are also a few other ways.
list = ["apple", "bannana", "custard", "shoe", "ant", "police", "python"] newList = [] for word in list: if word.startswith('a'): newList.append(word) print newList ['apple', 'ant']