Here is a puzzle for python programmers (python3+):

Find how a is defined (for example, a = 2 + True), with each underscore representing a character (there is no trail of whitespaces on the left and right)

a = _____


Edit for narrowing down the answer:

Here are the only characters you can work with: , ,, ", +

  • $\begingroup$ You should specify the version of Python. For example, in python 2.*, a = ur' ' would've worked. It doesn't in newer versions. $\endgroup$ Oct 14 '20 at 16:04


" """


This is simply the concatenation of a single space " " and the empty string "". The three quotation marks on the right are not parsed as a triple quote because the first one is paired with the one before the space.


If I'm reading the puzzle correctly, easiest answer would be

a=' '*1


The output is two spaces, and there are 5 underscores for the value of a. Output is achieved by concatenating a to a, so we know a must be a single space, achieved using 5 characters. In Python a string can be duplicated using multiply, so we have the string of a single space (3 characters), multiplied by 1 (an additional two characters).

  • 1
    $\begingroup$ There are lots of ways to burn the two excess characters: " "## f" "; r' '; (' ') or even " ";\ I'm sure there are more. $\endgroup$ Oct 14 '20 at 17:04
  • $\begingroup$ @PaulPanzer Yeah, there are a ton. I just figured my answer was the easiest to explain to a non-programmer while still looking "pythony" (I forget the term pythonistas use to describe python code) $\endgroup$ Oct 14 '20 at 18:48
  • 4
    $\begingroup$ I suspect OP had one very specific answer in mind and underestimated how many other ways there are, cf their edits. $\endgroup$ Oct 14 '20 at 18:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.