How can I create a subset of WordList[] that contains only the words that start with "g"?


closed as off-topic by Artes, Carl Lange, MarcoB, corey979, Coolwater May 9 at 14:12

This question appears to be off-topic. The users who voted to close gave these specific reasons:

  • "This question cannot be answered without additional information. Questions on problems in code must describe the specific problem and include valid code to reproduce it. Any data used for programming examples should be embedded in the question or code to generate the (fake) data must be included." – Artes, Coolwater
  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Carl Lange, MarcoB
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 3
    $\begingroup$ In general, it is a bad idea to give a title to a question that asks for a different thing than the question itself. $\endgroup$ – Henrik Schumacher May 9 at 9:36

You can use Select or Count or CountsBy with StringStartsQ:

Short @ %

{gab, gabardine, gabble, gabby, << 1213 >>, gyro, gyroscope, gyroscopic}

To get the counts

Length @ Select[StringStartsQ["g"]]@WordList[]


Count[WordList[], _?(StringStartsQ["g"])]


CountsBy[StringStartsQ["g"]] @ WordList[]

<|False -> 38907, True -> 1220|>

  • $\begingroup$ The OP is asking for a subset, not how many are there... I thing you should remove Length and Count $\endgroup$ – J42161217 May 9 at 9:32
  • 2
    $\begingroup$ @J42161217, good point. I went with the title: "Count the ..." $\endgroup$ – kglr May 9 at 9:35

Not the answer you're looking for? Browse other questions tagged or ask your own question.