Python: unexpected indent

Discussion in 'Mac Programming' started by moonman239, Jan 21, 2015.

  1. moonman239 macrumors 68000

    Joined:
    Mar 27, 2009
    #1
    Ran this script both on the latest version of Python and on Python 2.7.6. For some reason, there's an indent at print(data) that I saw just now. I use TextWrangler - got any tips to help see and fix problems like this?
    Code:
    #!/usr/bin/pythonw
    loop = 0
    data = {}
    while loop == 0:
    	theInput = input("Please type in either data or a command.")
    	if isinstance(theInput,int):
    	    binInput = bin(theInput)
    	    data.add(theInput)
    		print(data)
    
     
  2. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #2
    The code under the while has 8 spaces instead of 4.

    Edit: also, the last line is indented for no reason.
     
  3. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #3
    menu: View > Text Display > Show Invisibles

    menu: View > Text Display > Show Spaces


    Many programming editors have similar features.
     

Share This Page