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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T11:28:50+00:00 2026-06-10T11:28:50+00:00

In the following code; all_digits = set(range(10)) print all_digits for i in range(102,167): digits

  • 0

In the following code;

all_digits = set(range(10))
print all_digits
for i in range(102,167):
    digits = set(k for k in (str(i)))
    if len(digits) != 3:
        continue
    print "digits:", digits
    remaining_digits = all_digits - digits
    print "remaining:", remaining_digits

The digits set contains 3 elements. I want a set difference of them, however, remaining_digits always have all digits. What am I doing wrong here?
Here is a sample from output I am getting;

set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
digits: set(['1', '0', '2'])
remaining: set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
digits: set(['1', '0', '3'])
remaining: set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
digits: set(['1', '0', '4'])
remaining: set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
digits: set(['1', '0', '5'])
remaining: set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
digits: set(['1', '0', '6'])
remaining: set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
digits: set(['1', '0', '7'])
remaining: set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
digits: set(['1', '0', '8'])
remaining: set([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
  • 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-10T11:28:51+00:00Added an answer on June 10, 2026 at 11:28 am

    all_digits is a set of the ten integers 0 through 9, whereas digits is a set of 1-character strings like "0". Since the types are different, the set difference doesn’t work as expected.

    To make it work like you want, either use all integers or use all strings, e.g.:

    all_digits = set(map(str, range(10)))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I write the following code all the time to handle when the enter key
The following code works in all browser but IE8 and below. // Create Paragraph
The following code works in all browsers apart from IE6... var mylib = {
With the following code i detect all squares in a gray scale image: for
With the following code I get all the pages I admin on Facebook using
I use the following code to fill all empty keys in sub-arrays with ``
I have the following code: function build_all_combinations(input_array){ array = [1,2,3] limit = array.length -
Suppose I have the following code to collect all the possible combinations. abArray =
Im using the following code to output all the nodes from the xml shown.
I have the following code: Tag.find_all_by_company_id(4).each.collect{|tag| tag.name }.join(,) (Essentially I'm trying to build a

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.