How does my code differ from the solution?

to_you = “”“Stranger, if you passing meet me and desire to speak to me, why
should you not speak to me?
and why should I not speak to you?”""
print(to_you)

keep getting “Did you set to_you to the given Whitman poem?”

1 Like

I am getting the same and can’t seem to see how my entry is different to the solutions - they seem to be written out the same for me? Did you manage to get it to run eventually?

In python, you can make a comment like this:

"""This is a comment"""

And in your code, you used three quotation marks. This means python reads the string a a comment. You could try wrapping the quote in single quotation marks (‘Text here.’)

Link to exercise: Learn Python 3: Syntax: Multi-line Strings

The instructions ask the user to assign the following to the variable to_you:

Stranger, if you passing meet me and desire to speak to me, why
  should you not speak to me?
And why should I not speak to you?

Note that the second line of the string begins with two spaces. They should be included in the string that is assigned.

Also note that a multi line-string is actually just a string. It is not a comment, even though some programmers use it as such. Delimiting a string with """ at both ends does not create a string that differs in type from one that is created via using ''', ", or ' as the delimiter. Using """ or ''' as delimiters simply makes it easier to include quotes or line breaks within.

1 Like

I to am getting a error with an apparently identical string. I think it’s to do with the automatic line break in the editor rather than true line breaks, which depends on editor settings. Any way to show non-printing characters in the editor?

def Multiplexer(a,b,s):
    return b if s else a

print(Multiplexer(0,0,0))
print(Multiplexer(0,1,0))
print(Multiplexer(1,0,0))
print(Multiplexer(1,1,0))
print(Multiplexer(0,0,1))
print(Multiplexer(0,1,1))
print(Multiplexer(1,0,1))
print(Multiplexer(1,1,1))

Why is the answer 00110011 instead of 00110101?

The first answer is the one given in the exercise while I think the second should be the answer because we choose b if s is 1 and b has a pattern of 0101 when s is 1

I was also getting an error and then realized I had typed it out as if typing in a text editor - started with “”" followed by the text with the proper spacing and then finished by adding “”" at the end. I wasn’t following the rules for a comment.

But just like previous lessons where the beginning and endings are done first (often the end is automatically shown when the beginning is typed for other functions ) and then the code is inserted, if you type the six quotation marks (single or double) and then type the text in between them, it works.

1 Like

Yeah, many editors strive to assist the user by anticipating what the user intends to do. Until we get accustomed to how a particular editor does this, using it may be a bit awkward.