Ask Your Question
0

IndentationError: unexpected indent

asked 2015-09-19 01:54:19 +0100

this post is marked as community wiki

This post is a wiki. Anyone with karma >750 is welcome to improve it.

How to fix the errors,....

set_verbose(-1)
@interact
def _(n=slider(-5,20,step_size=1),b=slider(1,20,step_size=1),auto_update=False):
    f= n*x+b
    pt=plot(n*x+b,(x,-2,10))
    dot= point((0,b),pointsize=80,rgbcolor=(1,0,0))
    show(dot+pt)

gives the following error

Error in lines 1-9
Traceback (most recent call last):
  File "/projects/28f4a164-4f32-45a9-9846-82b90ee6d545/.sagemathcloud/sage_server.py", line 879, in execute
    exec compile(block+'\n', '', 'single') in namespace, locals
  File "<string>", line 4
    def _(f=input_box(x**Integer(2),width=Integer(20)),
    ^
IndentationError: unexpected indent

I tried to use spaces, and tabs. I am kinda new to python and sage.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2015-09-19 05:32:35 +0100

vdelecroix gravatar image

Hello,

Python is very strict about indentation (but not about whether you should use space or tab though)

This is good

x = 3
def my_function():
    s = "my x is %s" % x
    print s

These are bad

x = 3
  def my_function():
    s = "my x is %s" % x
    print s

(the f is indented but should not)

x = 3
def my_function():
      s = "my x is %s" % x
    print s

(the indentations are different in the two lines)

Vincent

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-09-19 01:54:19 +0100

Seen: 2,333 times

Last updated: Sep 19 '15