-1

I am a novice in python. I just extended the Hello World program:

import sys

def first(n):
    print "Hi Man"+" Huuuuuu"
    if len(sys.argv)>1: print sys.argv[1]

def second():
    print "Huuuuuuuuuuu"    
    first(7)

if __name__=='__main__':
    second()

I get the error:

File "first.py", line 11
    first(7)
    ^
IndentationError: unexpected indent

I read What to do with "Unexpected indent" in python?, but I can't find the error.

I ran with python -t command:

python -t first.py
first.py: inconsistent use of tabs and spaces in indentation
  File "first.py", line 12
    first(7)
    ^
IndentationError: unexpected indent

Thanks for your help.

Community
  • 1
  • 1
Andy Markman
  • 127
  • 1
  • 12
  • 2
    I copy paste your code and get no errors. Are you sure the code you've shared is *exactly* what you're running? – Jon Surrell Jul 18 '16 at 06:12
  • Make sure your not using a mix of 4 spaces and tab. – Eduard Jul 18 '16 at 06:13
  • 1
    There is almost certainly an indentation error in your code at line 12 (thus the IndentationError) . Calling a function within a function is not your issue. Fix the indentation. – Michael Jul 18 '16 at 06:14
  • @JonSurrell I just copied the code from my question and it worked ? It was not working before. – Andy Markman Jul 18 '16 at 06:15
  • Seems that you are mixing tabs and spaces. – Psytho Jul 18 '16 at 06:16
  • @Alex.S yes, it is the exact issue. I got it now, the first(7) code I used tab.... – Andy Markman Jul 18 '16 at 06:18
  • Possible duplicate of [What to do with "Unexpected indent" in python?](http://stackoverflow.com/questions/1016814/what-to-do-with-unexpected-indent-in-python) – Psytho Jul 18 '16 at 06:20

1 Answers1

2

Python generally works by the indentation instead of curly braces block. In your case check the blank spaces in front of first(7) statement are matching with the blank spaces with the first print statement.

Check if you have putted the tab character in one of the statement. generally we put the 4 blank spaces in front of the statement.