Ask Your Question
0

A confusing syntax error when using elif

asked 2015-04-14 11:04:19 -0500

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 11:12:28 -0500

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 11:27:19 -0500 )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 13:27:14 -0500 )edit
1

@kcrisman Thank you Kcrisman. Sorry for this delaying.

Haron gravatar imageHaron ( 2015-04-15 13:07:28 -0500 )edit

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

kcrisman gravatar imagekcrisman ( 2015-04-15 13:17:28 -0500 )edit

That is the person who gave you this answer :)

kcrisman gravatar imagekcrisman ( 2015-04-15 15:49:44 -0500 )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 11:04:19 -0500

Seen: 115 times

Last updated: Apr 14 '15