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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T13:02:36+00:00 2026-06-05T13:02:36+00:00

Why am I getting a strange 0 2 result when I give this to

  • 0

Why am I getting a strange 0 2 result when I give this to Python?

#tuples ~wtF?
a=()
b=(a)
c=(a,1)
len(b)
len(c)

NB: I get an expected 1 2 result for lists:

a=[]
b=[a]
c=[a,1]
len(b)
len(c)

This is happening on Linux:

$ python --version
Python 2.7.2+

Edit: wrt answers so far

So is this somehow because of the , in the c=(a,1) assignment?

>>> print b
()
>>> print c
((), 1)
  • 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-05T13:02:44+00:00Added an answer on June 5, 2026 at 1:02 pm

    The brackets don’t make it a tuple – the comma does. Consider:

    >>> 5 * (3 + 2)
    25
    

    The brackets there mean ‘do this first’. The brackets in:

    b=(a)
    

    Mean the same. So, this is equivalent to

    b = a 
    

    so b is a will be True.

    To make b a tuple containing the empty tuple, you need to do:

    b = a, 
    

    Again, the brackets don’t make it a tuple (except for the special case of () is the empty tuple), the comma does.

    For the edit,

    c = (a, 1)
    

    Since a = (), this is the same as:

    c = ((), 1)
    

    ie, it is a tuple containing the empty tuple and 1. () is always the empty tuple (same as [] is the empty list), but this it the only time the brackets mean ‘tuple’. The above is the same as:

    c = (), 1
    

    Though normally people do include the brackets here (and the repr and str of tuples always do), this is for style rather than because they’re meaningful.

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

Sidebar

Related Questions

I'm not sure why am I getting this strange result. Can someone please shed
I'm running testunit (with machinist) and getting this very strange result when I run
Im getting an strange result with this particular code. Let me explain my self
I am getting a strange result in the following C code. int main() {
i'm getting a very strange result from my database query, i was hoping someone
Possible Duplicates: Getting strange output when printing result of a string comparison Hi all,
I'm getting strange results testing the return value from a function. This code is
This is strange... I'm displaying results in an HTML table but I'm getting a
I'm getting a very strange result when I try to use string.trim to remove
I'm trying to do something rather simple but I'm getting a strange result. I

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.