Python – Error “mismatched input” expecting DEDENT

python

Following this tutorial I got the following error where y = 1;
I'm using Netbeans 6.5 for Python. thanks

      y=1
      ^

SyntaxError: line 8:3 mismatched input '' expecting DEDENT (temperatureconverter.py, line 8)

the following is the python code, format it for me thanks.

__author__="n"
__date__ ="$Jan 9, 2011 3:03:39 AM$"

def temp():
  print "Welcome to the NetBeans Temperature Converter."  
   y=1
   n=0
   z=input("Press 1 to convert Fahrenheit to Celsius, 2 to convert Celsius to Fahrenheit, or 3 to quit:")
    if z!=1 and z!=2 and z!=3:
        e=input("Invalid input, try again?(y or n)")
        if e==1:
            t=''
            temp()
        if e==0:
            t="Thank you for using the NetBeans Temperature Converter."
  print "Celsius Fahrenheit"  # This is the table header.
  for celsius in range(0,101,10):  # Range of temperatures from 0-101 in increments of 10
    fahrenheit = (9.0/5.0) * celsius +32 # The conversion
    print celsius, "       ", fahrenheit  # a table row
temp()

Best Answer

In the print statement you used 2 spaces to indent the line, while in the next one you put 3 spaces.

Whitespace is significant in Python. Specifically, if you have a certain level of indentation in one line you can't just use another one for the next line.

Related Topic