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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T16:14:59+00:00 2026-06-02T16:14:59+00:00

I was learning about dictionaries in Python and I created a simple program: #

  • 0

I was learning about dictionaries in Python and I created a simple program:

# Create an empty dictionary called d1
d1 = {}

# Print dictionary and length
def dixnary():
    print "Dictionary contents : "
    print d1
    print "Length = ", len(d1)

# Add items to dictionary
d1["to"] = "two"
d1["for"] = "four"

print "Dictionary contents :"
print d1
print "Length =" , len(d1)

# Print dictionary and length
print dixnary()

Now there’s a difference in the results when I use the print commands and when I use the dixnary function.

Using the print commands I get the result:

Dictionary contents:
<‘to’:’two’,’for:’four’>
Length = 2

and when I use the function dixnary, I get the results:

Dictionary contents:
<‘to’:’two’,’for:’four’>
Length = 2
None

Notice the None on the final line. This None gets added when I use the function dixnary. Why is this?

  • 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-02T16:15:00+00:00Added an answer on June 2, 2026 at 4:15 pm

    You’re attempting to print the return value of a function, but the function doesn’t return a value, so it returns the default value of None.

    The reason why it prints out other data is that you have print commands inside of the function. Just run the function (dixnary()), instead of printing it (print dixnary()).

    Or alternatively, have the program return the string, so you can do useful things with it.

    def dixnary():
        return "Dictionary contents :\n%s\nLength = %d" % (d1, len(d1))
    
    print dixnary()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm still learning about Objective-C memory management. I'm trying to implement several simple classes
I've recently began learning about QThreads and I've a program which runs a 4
Fairly new to python, forgive me if this is a basic question about learning
Learning about Explicit Cursors and trying to create my frst one.: SET SERVEROUTPUT ON
I'm just learning about custom controls in C# (window forms) I've created the below
I'm currently learning about pickling in Python and I'm confused with an error I'm
After learning about how to print out debug messages using Visual Studio's Tracepoint feature,
I'm learning about table design in SQL and I'm wonder how to create a
Learning about notifyAll made me question something about notify: in a typical situation we
After learning about the Action delegate in C# I've been looking for ways 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.