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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:57:18+00:00 2026-06-14T20:57:18+00:00

So for some background: I’ve been going through learning python the hard way and

  • 0

So for some background: I’ve been going through learning python the hard way and have taken a little break to try doing a few fun things, I came across on a suggestion on daniweb, to try create a program in which you enter in a list of characters and it will then print out any word that contain all those characters.

I’ve figured out how to do it manually, here’s the below code:

string = raw_input("Please enter the scrable letters you have: ")
for line in open('/usr/share/dict/words', 'r').readlines():
    if string[0] in line and string[1] in line and string[2] in line:
        print line,

But I somehow cannot figure out how to get it to work by using loops (that way the user can enter in a list of characters of any length. I figured something like the below would work, but it doesn’t appear to do so:

while i < len(string)-1:
   if string[i] in line: tally = tally + 1
   i = i + 1
if tally == len(string)-1: print line
else: i = 0

Any help in the right direction would be much appreciated, thanks.

  • 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-14T20:57:20+00:00Added an answer on June 14, 2026 at 8:57 pm

    Set operations can come in handy here:

    inp = set(raw_input("Please enter the scrable letters you have: "))
    with open('/usr/share/dict/words', 'r') as words:
        for word in words:
            if inp <= set(word):
                print word,
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Some background info: I am currently writing a bootloader in protected mode while learning
Some background info: I'm trying to run a server program in python 2.5.1 (the
Some background first. I have a .net client agent installed on each of the
Some Background I have noticed that setting the EditTemplate of a DataForm (from the
Some Background: I have a VS 2008 Deployment project I am not using the
Some background first. I am currently learning some stuff about monadic parser combinators. While
Some background: In Germany (at least) invoice numbers have to follow certain rules: The
Some background: As a personal project, I've been developing a kernel in c++. Things
Some background: We have some entity classes need to be serialized, so we implement
Some background: I am writing a application with several forms, etc. Users have to

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.