Ask Your Question
0

A confusing syntax error when using elif

asked 2015-04-14 18:04:19 +0100

Haron gravatar image

Dear All

This is my confusing problem:

sage: m=31
sage: if m%3==0:
....:     print m/3
....:     elif m%3==1:
....:         print (m-1)/3
....:
File "<ipython-input-2-ec9f38b42615>", line 3
  elif m%Integer(3)==Integer(1):
      ^
SyntaxError: invalid syntax

sage:

I do not copy-paste the code. I have ubuntu14.04 and my sage version is 6.5.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-04-14 18:12:28 +0100

Nathann gravatar image

The 'elif' should not be inside of the 'if'

http://www.tutorialspoint.com/python/...

edit flag offensive delete link more

Comments

Thank you. I understand.

Haron gravatar imageHaron ( 2015-04-14 18:27:19 +0100 )edit

@Haron - if this completely answered your question, please don't forget to "accept" by clicking the check mark, so that people coming to this site with the same question know they will find an answer. Thanks!

kcrisman gravatar imagekcrisman ( 2015-04-14 20:27:14 +0100 )edit
1

@kcrisman Thank you Kcrisman. Sorry for this delaying.

Haron gravatar imageHaron ( 2015-04-15 20:07:28 +0100 )edit

No problem, just a reminder for future visitors - glad Nathann could help!

kcrisman gravatar imagekcrisman ( 2015-04-15 20:17:28 +0100 )edit

That is the person who gave you this answer :)

kcrisman gravatar imagekcrisman ( 2015-04-15 22:49:44 +0100 )edit

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-04-14 18:04:19 +0100

Seen: 402 times

Last updated: Apr 14 '15