ady6831983 ady6831983 - 2 months ago 5
Python Question

Indentation error basic program

Hello I am beginner to python and am trying to learn, this is what i keep hitting when i execute the below code, where is the mistake

#!/usr/bin/python

def main():
num1=input("Enter the 1st #\t\t")
print "First # is\t:", num1
print
num2=input("Enter the 2nd #\t\t")
print "Second # is\t:",num2
print
num3=input("Enter the 3rd #\t\t")
print "3rd #is:,\t",num3
if(num1>num2) and (num1>num3):
print"Highest # is:\t",num1
elif(num2>num3) and (num2 >num1):
print"Highest # is:\t",num2
else:
print "The WINNER IS\n"
print num3

main()


Error:

python 1.py
File "1.py", line 4
num1=input("Enter the 1st #\t\t")
^
IndentationError: expected an indented block


Where is the indentation that i am missing?

Answer

You should indent your main function with spaces or tabs. (4 spaces is recommanded)

Like this:

def main()
    num=input()
    # rest of your main code

main()

I saw you allready did this for if/else, you should also do it for functions.

I recommand you take a beginner python course like te one of codecademy.

Comments