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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T16:22:21+00:00 2026-05-24T16:22:21+00:00

We have a question we ask at our office during interviews that goes like

  • 0

We have a question we ask at our office during interviews that goes like this. For the sake of consistency, I am restricting the context of this to python. I’m sure there are other answers but I’m really only interested in python answers.

Write me a function named say that when called like this:

>>> say('Hello')('World')

It ONLY Prints (not returns):

>>> say('Hello')('World')
Hello World
>>> 

We got into a meta discussion after the interview today where I stated that I am always hoping the applicant will answer with the following.

def say(x):
 print "Hello World"
 return lambda a:None

I realized that there is a possibility of shortening this further by replacing the lambda function with a built in of some sort that returns None but I’ve dug and can’t seem to find one that is shorter than lambda a:None

So the overall question here is…

Can you think of a way to make this shorter, as in less overall characters (ignoring line breaks). Any import statements are counted in your character count. (52 Characters)

UPDATE

(39 Characters)

>>> def p(x):
...  print "Hello",x
>>> say=lambda x:p
>>> say("Hello")("World")
Hello World
>>>

Python 3 Answer
(48 Characters)

>>> def say(x):
...  return lambda a:print("Hello World")
>>> say("Hello")("World")
Hello World
>>> 
  • 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-24T16:22:22+00:00Added an answer on May 24, 2026 at 4:22 pm

    Python 2.x answers

    The obvious answer that doesn’t actually count because it returns the string instead of printing it:

    >>> say = lambda x: lambda y: x + " " + y
    >>> say('Hello')('World')
    'Hello World'
    

    This one is 45 characters counting newlines:

    def p(x):
     print "Hello World"
    say=lambda x:p
    

    This method drops it down to 41 characters but it looks kind of odd since it uses one argument but not the other:

    def p(x):
     print "Hello",x
    say=lambda x:p
    

    Python 3.x answers

    36 characters:

    >>> say=lambda x:lambda y:print(x+" "+y)
    >>> say('Hello')('World')
    Hello World
    

    38 characters:

    >>> say=lambda x:print(x,end=' ') or print
    >>> say('Hello')('World')
    Hello World
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This seems like an incredibly dumb question to have to ask, but how do
I would like to ask this question to those people who have an experience
I have a question that I'm ashamed to ask, but I'm going to have
[i meant to ask this question on StackOverflow...] I have been using VisualSVN Server
I ask this question in anticipation as part of a project. I have experience
Sorry, this's my first time to ask a question here. So, I don't have
I have ask this kind of question before, but it seems my previous question
I Know this is a dumb question but i have to ask. I have
I have a question from this stackoverflow question about iPhone storage . Like I
I am fairly new to this discussion but I HAVE to ask this question

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.