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 6877215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:34:25+00:00 2026-05-27T04:34:25+00:00

I am doing a project for my programming class, here are the 5 things

  • 0

I am doing a project for my programming class, here are the 5 things that I am working towards. Thanks for your help!

  1. list of valid words will be provided in a words.txt
  2. ask for input that only accepts a combination of 2-8 letters
  3. Ex. input would be “polo”
  4. Find all possible valid words of this input from inside words.txt
  5. Possible outcomes, “poo” “pool” “loop” “polo”

    import random
    import itertools
    
    file_name='words.txt'
    DEBUG=True
    
    def load_words():
        try:
            f=open(file_name,'r')
            str1=f.read()
            f.close()
        except:
            print('Problem opening the file',file_name)
        list1=[]
        list1=str1.split()
        if DEBUG:
            length=len(list1)
            print('Number of words is',length)
            print(list1[0],list1[length//2],list1[-1])
            for i in range(10):
                print(list1[random.randint(1,length)])
        return(list1)
    
    def is_valid(str1,list1):
        valid=False
        count=0
        if str1 in list1:
            valid=True
        return valid
    
    def generate(letters):
        print(len(letters))
        count=1
        answers=[]
        for length in range(2,len(letters)+1):
            for x in itertools.permutations(letters,length):
                word=''
                for let in x:
                    word+=let
                print(word)
                if is_valid(word):
                    answers.append(word)
                count+=1   
            print(count,x)
            return(answers)
    
    def main():
        words=load_words()
        generate('abcde')
        guess=input('Check a word')
        if is_valid(guess.upper(),words):
            print(guess,'is a real word')
        else:
            print(guess,'is not a real word')
    
    main()
    
  • 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-05-27T04:34:26+00:00Added an answer on May 27, 2026 at 4:34 am

    as far as the error is concerned
    print(list1[random].randint(1,length)) should be changed to
    print(list1[random.randint(1,length)])

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

Sidebar

Related Questions

I'm currently doing a project for a Beginner C programming class where i'm supposed
I am working on a class library (DLL) project in Visual Studio 2008; programming
I'm doing a project that involves comparing programming languages. I'm computing the Ackermann function.
I am working on a little hobby project and am experimenting with doing things
I was doing a project for computer course on programming concepts. This project was
I'm doing a project in seam that requires restful URLs. I have a view
I'm currently doing a project in C# working with windows forms. During the course
I am doing project in powerpoint 2007 automation. In that i am using macro
Long story: I am doing a project for my functional programing class, and I
I just need some quick help on syntax. I'm doing a WPF project and

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.