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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T20:06:15+00:00 2026-05-24T20:06:15+00:00

I tried writing this code: def smaller(x, y): if x > y: print(y) else:

  • 0

I tried writing this code:

def smaller(x, y):
    if x > y:
        print(y) 
    else:
        print(x) 

print(smaller(2, 3))

I got this result:

>>>
2
None

Where did the None come from? What does it mean?


See also

The accepted answer explains the importance of returning a value from the function, rather than printing it. For more information, see What is the purpose of the return statement? How is it different from printing?.

To understand the None result itself, see What is a 'NoneType' object?.

If you are printing inside the function in order to see multiple values, it may be better to instead collect those values so that they can be printed by the calling code. For details, see How can I use `return` to get back multiple values from a loop? Can I put them in a list?.

  • 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-05-24T20:06:17+00:00Added an answer on May 24, 2026 at 8:06 pm

    It’s the return value of the function, which you print out. If there is no return statement (or just a return without an argument), an implicit return None is added to the end of a function.

    You probably want to return the values in the function instead of printing them:

    def jiskya(x, y):
        if x > y:
            return y
        else:
            return x
    
    print(jiskya(2, 3))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I got tired of writing the following code: /* Commenting out irrelevant parts public
Is there a better way to write this code? i tried function(){}(); but i
Please let me know how to bug fix this code . I tried and
this piece of code is driving me crazy. I'm trying to print a help
I find myself writing this code a lot: private int _operationalPlan; public int OperationalPlan
When I am writing my code, I find the following situation many times: def
I tried writing a program in Java using regex to match a pattern and
I'm trying to learn Lisp (elisp, actually), and I tried writing the following function
I have tried the following program for writing the contents into Spreadsheet. I downloaded
I have a business user who tried his hand at writing his own SQL

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.