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

  • Home
  • SEARCH
  • 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 1109889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:18:32+00:00 2026-05-17T02:18:32+00:00

The if statement below has a problem in it somewhere and I can not

  • 0

The if statement below has a problem in it somewhere and I can not figure it out. Any conventions or method misuses that might be causing it to not function right? checkList is a user inputed sentence and lis is a large list of words.

def realCheck(checkList):  
        string = "".join(checkList)  
    print string  
    wordList = string.split()  
    if match(wordList, lis).sort(key=str.lower) == wordList.sort(key=str.lower):  
        return True  
    else:  
        return False  
  • 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-17T02:18:33+00:00Added an answer on May 17, 2026 at 2:18 am
    1. If checkList is a string, then there
      is no need for "".join(checkList).
      It just gives you back the same
      string:

      In [94]: checkList="This is a sentence"    
      In [95]: "".join(checkList)
      Out[95]: 'This is a sentence'
      
    2. The first line, string =
      "".join(checkList)
      has the wrong
      indentation. Move it back to be
      flush with the other lines in the
      definition.

    3. Don’t name a variable string. It
      overrides the standard Python module
      of the same name.

    4. Presumably match(wordList, lis)
      returns a list. The sort method
      sorts the list, and returns None.
      Since None == None is True,

      if match(wordList, lis).sort(key=str.lower) ==  wordList.sort(key=str.lower):
      

      is always true.

      More likely, what you want is

      sorted(astr.lower() for astr in match(wordList, lis))==sorted(astr.lower() for astr in wordList)
      

      Unlike the sort method, the
      sorted function returns the
      sorted list.

      As Alex Martelli points out,

      sorted(match(wordList, lis),key=str.lower)==sorted(wordList,key=str.lower)
      

      always has the same truth value as

      sorted(match(wordList, lis))==sorted(wordList)
      

      So using str.lower as the key
      for sorting (rather than as a
      transformation before comparing with
      ==) is probably not what you want.

    5. The statement

      if condition:
          return True
      else:
          return False
      

      can be simplified to

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

Sidebar

Related Questions

I'm having a very odd problem that I can't seem to track down. Any
Can someone explain the statement below to me with a working sample/example. thanks in
I would like to avoid the if statement below. Can I somehow copy the
I have a problem when trying to execute this update statement (below) using C#
Is better to use the below statement Convert.ToInt32(0 + stringValue) If not then why?
Problem that i face: -I have an input string, a SQL statement that i
I have a database table that has a structure like the one shown below:
I have a mySQL statement that looks like below. It tries to select all
Im stuck with the below problem. Problem Statement: Given a non-negative int n, return
Solution: The problem below was caused by a Divx javascript that overwrote a core

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.