IndentationError: expected an indented blockPython for Security Professionals Course

Begin Learning Cyber Security for FREE Now!

FREE REGISTRATION
Already a Member Login Here

Home Forums Courses Python for Security Professionals Course IndentationError: expected an indented block

This topic contains 3 replies, has 3 voices, and was last updated by  Paul Rouk 2 years, 12 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #87321

    riswankp
    Participant

    Hi Perry,

    Thanks for the great course.

    I am trying to do the code along with your videos, but when ever i use print in if, for etc, i am getting below error. Can you please help how to sort this issue.

    `>>> def func1():
    … print “Hello WOrld”
    File “<stdin>”, line 2
    print “Hello WOrld”
    ^
    IndentationError: expected an indented block

    #87747

    andersmarkc
    Participant

    Try: print(“Hello World”)

    If you are using the new version of python.

    #87748

    andersmarkc
    Participant

    Hopes it helps you 🙂

    #87817

    Paul Rouk
    Participant

    Keep in mind that one thing which is unique to Python is that spaces/tabs actually mean something. The error message “IndentationError: expected an indented block” would seem to indicate that your print statement should be indented to match the line above.

    In most programming languages, spaces or indentation are just used to make the code look better and be easier to read. In Python, it is actually part of the programming language. Putting in an extra space or leaving one out where it is needed will generate an error message. It isn’t that bad once you get used to it, but can definitely cause a lot of headaches when you first start learning the language.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

Our Revolution

We believe Cyber Security training should accessible for everyone, everywhere. Everyone deserves the OPPORTUNITY to learn, begin and grow a career in this fascinating field. Therefore, Cybrary is the world's largest community where people, companies and training come together to give everyone the ability to collaborate in an open source way that is revolutionizing the cyber security educational experience.

We recommend always using caution when following any link

Are you sure you want to continue?

Continue
Cancel