Ask Your Question
0

A confusing syntax error when using elif

asked 10 years ago

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.

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 10 years ago

Nathann gravatar image

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

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

Preview: (hide)
link

Comments

Thank you. I understand.

Haron gravatar imageHaron ( 10 years ago )

@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 ( 10 years ago )
1

@kcrisman Thank you Kcrisman. Sorry for this delaying.

Haron gravatar imageHaron ( 10 years ago )

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

kcrisman gravatar imagekcrisman ( 10 years ago )

That is the person who gave you this answer :)

kcrisman gravatar imagekcrisman ( 10 years ago )

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: 10 years ago

Seen: 421 times

Last updated: Apr 14 '15