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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:31:13+00:00 2026-06-03T23:31:13+00:00

I am novice in Python. I would like to enter 10 elements into the

  • 0

I am novice in Python.
I would like to enter 10 elements into the list.
Below program appends 10 elements to each of the list.
But below program prints 11 objects in list why?
I got this program from http://www.learnpython.org/page/Basic%20Operators link.
I wanted to know x = object(), what does it mean?

x = object()
y = object()
i = 0
# change this code
x_list = [x]
y_list = [y]
while(i < 10):
    x_list.append((10))
    y_list.append(11)
    i = i + 1
#x_list = [x]
#y_list = [y]
big_list = x_list + y_list

print "x_list contains %d objects" % len(x_list) # prints 11 objects, #Why?
print "y_list contains %d objects" % len(y_list) # prints 11 objects, #Why?
print "big_list contains %d objects" % len(big_list)
print x_list.count(10)
print y_list.count(11)
    print big_list.count(10)
# testing code
if x_list.count(x) == 10 and y_list.count(y) == 10:
    print "Almost there..."
if big_list.count(x) == 10 and big_list.count(y) == 10:
    print "Great!"
  • 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-03T23:31:14+00:00Added an answer on June 3, 2026 at 11:31 pm

    The learnpython.org basic operators page provides some examples of using arithmetic operators in different contexts, including lists. Based on quickly reading the tutorial in that page, probably the answer that the page authors were after would be:

    x_list = [x] * 10
    y_list = [y] * 10
    big_list = x_list + y_list
    

    Which would create a list with 10 x:s in it.

    You were using a loop to do that, which is much more flexible way. A more pythonic way to fill a list by using a loop would be e.g. to use list comprehensions:

    x_list = [x for i in xrange(10)]
    

    or use a for loop, then you don’t have to keep track of the index yourself:

    for i in xrange(10):
        x_list.append(x)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I convert python dicts with simplejson, but I'd like to customise the output for
Python comes with the handy dir() function that would list the content of a
I'm a newbie in boost.python and i'm getting this error that I would like
I had no issue with Django + uWSGI + Cherokee. BUt I would like
Python novice here. I am using python2.7.2 on Windows7. I have installed the PyWin32
I am novice to python and I am trying to understand a basic error
I'm a python novice and am struggling with some concepts here - any help
I'm a novice-to-intermediate JavaScript/jQuery programmer, so concrete/executable examples would be very much appreciated. My
So first let me say that I am a novice at Python and functions
I have a set of png images that I would like to process with

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.