Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8069747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:09:41+00:00 2026-06-05T13:09:41+00:00

hi so im using python and i’m trying to create a function that lets

  • 0

hi so im using python and i’m trying to create a function that lets me generate words made up of 2 letters. i also want to count how many of the words generated are actually in the dictionary.

this is what i have so far:

alphabet = ('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o',
            'p','q','r','s','t','u','v','w','x','y','z')
count1 = 0
text = " "

def find2LetterWords():
    for letter in alphabet:
        text += letter
        for letter in alphabet:
            text +=letter
    print text

this is the code i have written so far and i know its not right. i was just experimenting. so yea it would be great if u could help me out. thx.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T13:09:43+00:00Added an answer on June 5, 2026 at 1:09 pm

    Answer edited based on comments:

    def find2LetterWords():
         #this generates all possible 2-letter combos with a list comprehension
         words = [first + second for second in alphabet for first in alphabet]
         #create a new list with only those words that are in your_dictionary (a list)
         real_words = [word for word in words if word in your_dictionary]
         return real_words
    

    If you want a nice one liner, with no function:

    [word for word in [first + second for second in alphabet for first in alphabet] if word in your_dictionary]
    

    Obviously, replace your_dictionary with whatever the name of your dictionary is.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Python I want to create a symbolic link pointing to a path that
Using Python v2.x, I have 3 variables that I want to ask the user
Using Python's Imaging Library I want to create a PNG file. I would like
Using Python I want to create a property in a class, but having the
Using Python, I'm trying to convert a sentence of words into a flat list
Using Python and regex I am trying to find words in a piece of
Using Python, I want to know whether Java is installed.
Using Python I want to randomly rearrange sections of a string based on a
Using Python, I'm trying to rename a series of .txt files in a directory
Using python 3.2, I am trying to decode bytes using str(bytes, cp1251) but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.