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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:27:06+00:00 2026-06-03T04:27:06+00:00

I cannot add the integer number 1 to an existing set. In an interactive

  • 0

I cannot add the integer number 1 to an existing set. In an interactive shell, this is what I am doing:

>>> st = {'a', True, 'Vanilla'}
>>> st
{'a', True, 'Vanilla'}
>>> st.add(1)
>>> st
{'a', True, 'Vanilla'}   # Here's the problem; there's no 1, but anything else works
>>> st.add(2)
>>> st
{'a', True, 'Vanilla', 2}

This question was posted two months ago, but I believe it was misunderstood.
I am using Python 3.2.3.

  • 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-03T04:27:08+00:00Added an answer on June 3, 2026 at 4:27 am
    >>> 1 == True
    True
    

    I believe your problem is that 1 and True are the same value, so 1 is “already in the set”.

    >>> st
    {'a', True, 'Vanilla'}
    >>> 1 in st
    True
    

    In mathematical operations True is itself treated as 1:

    >>> 5 + True
    6
    >>> True * 2
    2
    >>> 3. / (True + True)
    1.5
    

    Though True is a bool and 1 is an int:

    >>> type(True)
    <class 'bool'>
    >>> type(1)
    <class 'int'>
    

    Because 1 in st returns True, I think you shouldn’t have any problems with it. It is a very strange result though. If you’re interested in further reading, @Lattyware points to PEP 285 which explains this issue in depth.

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

Sidebar

Related Questions

I know this may be basic but I cannot seem to add a member
I understand that I cannot add preconditions on an interface implementation. I have to
In following code the issue is, that I cannot test dao.add() without using dao.list().size()
I'd like to add an image to a UIToolBar that a user cannot interact
Im sitting here scratching my head with a validation problem in ASP MVC3. Somehow
Problem description There are different categories which contain an arbitrary amount of elements .
I have a little disturbing problem in here! an using symfony 1.4 with Doctrine!
I am programming under Delphi Prism for Mono. I keep getting this error, Cannot
Is there any way to detect change in an integer? Such as creating a
There are essentially 2 questions: For excel's .sort function: How do I add keys

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.