In ' while ' or ' for ' loop in Sage, can one use ' { ' and ' } ' like C program?

1,397 views
Skip to first unread message

Santanu Sarkar

unread,
Feb 24, 2011, 1:49:35 AM2/24/11
to sage-s...@googlegroups.com

Jason Grout

unread,
Feb 24, 2011, 1:54:53 AM2/24/11
to sage-s...@googlegroups.com
On 2/24/11 12:49 AM, Santanu Sarkar wrote:


> In ' while ' or ' for ' loop in Sage, can one use ' { ' and ' } '
like C program?

No. In Python (the language you are using when you write Sage code) use
indentation to indicate blocks of code.

for i in range(100):
print i
print i^2

See
http://docs.python.org/tutorial/introduction.html?highlight=indentation#first-steps-towards-programming
for a longer introduction.

Thanks,

Jason

William Stein

unread,
Feb 24, 2011, 3:52:27 PM2/24/11
to sage-s...@googlegroups.com, Jason Grout

You an also use comments if you want to have some sort of explicit end
marker.

for i in range(100):
print i
print i^2

# end for

I used to do that when I was first learning Python.

William

Santanu Sarkar

unread,
Feb 25, 2011, 8:39:27 AM2/25/11
to sage-s...@googlegroups.com
Thank you very much.

> --
> To post to this group, send email to sage-s...@googlegroups.com
> To unsubscribe from this group, send email to sage-support...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sage-support
> URL: http://www.sagemath.org
>

Reply all
Reply to author
Forward
0 new messages