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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:44:02+00:00 2026-05-16T18:44:02+00:00

level: beginner word= ‘even’ dict2 = {‘i’: 1, ‘n’: 1, ‘e’: 1, ‘l’: 2,

  • 0

level: beginner

word= 'even' 
dict2 = {'i': 1, 'n': 1, 'e': 1, 'l': 2, 'v': 2} 

i want to know if word is entirely composed of letters in dict2
my approach:

step 1 : convert word to dictionary(dict1)

step2:

for k in dict1.keys(): 
        if k in dict2: 
               if dict1[k] != dict2[k]: 
                   return False 
               return True 

by adding a print statement i can see that this simply ends too early
e.g. as soon as the first IF condition is met the loop exits and i won’t get a correct answer. i think this is easy but google and python doc didn’t return any good
hints so i’m trying here.

Thanks Baba

UPDATE

the number of times that each letter ocurs in the word needs to be smaller or equal to the number of times it apears in dict2. That way i am guaranteed that word is entirely made up of elements of dict2.

for k in word.keys(): # word has ben converted to key already
    if k not in hand:
        return False
    elif k in hand:
      if word[k] > hand[k]:  
          return False
return True
  • 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-16T18:44:02+00:00Added an answer on May 16, 2026 at 6:44 pm

    You only want to return true after all the checks, so stick it after the loop. Here it is as a straight modification of your code:

    for k in dict1.keys(): 
        if k in dict2: 
            if dict1[k] != dict2[k]: 
                return False 
    return True 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm still a beginner to programming in high-level programming languages, so I don't know
(VB Express Level: Beginner) I want to do following, A column from Workbook 1
whats is wrong with following? (Level:Beginner) I want to add the answers obtained after
level: beginner Below snippet is part of code that counts letters in an array.
level: beginner the following code will print 'False' def function(x): if len(x) == 5:
Question : Beginner Level Code: Pure Javascript I had created a web page in
Beginner level question Scenario: Have simple string cocantation tool, that I might expand later
This is a beginner level question for asp.net MVC I have the following code
I'm a beginner level programmer trying to make a game app for the iphone
i am writing javascript code on nodepad++,i am at beginner level and write just

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.