Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Coding Problem?

def printme(str):

print("Hello")

printme()

I am getting a IndentationError: expected an indented block error, I am trying to see if I simply type the variable will it return the

variables defined commands. Can someone explain this to me

Update:

This is a python question

2 Answers

Relevance
  • 4 years ago
    Favorite Answer

    Your "def" statement begins a function definition. The statement that that make up the function (describe what's done when the function is executed) immediately follow the def statement and *must be indented*.

    Python uses indentation instead of symbols or words, to group lines. So try this:

    def printme(s):

    .... print(s) # type spaces or a tab instead of .... at the front

    printme("Hello")

    That's changed a bit. Your original version expected an argument and would have failed with "printme() expected 1 argument but found 0" or something like that, because the printme() call at the bottom didn't provide an argument.

    The .... token is a substitute for a tab or spaces. Y!A removes "extra" spaces, so you can't paste code here and have it appear properly indented.

  • 4 years ago

    I agree with husoski. It depends on what the question is asking for. Another working solution would be:

    def printme():

    ... print ("Hello")

    printme()

    Remember to use spaces or a tab instead of "... ".

Still have questions? Get your answers by asking now.