0

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

1 Answer 1

1

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'] 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.