On Mon, Feb 6, 2012 at 3:12 PM, Chappman <chappman....@gmail.com> wrote:
> Hi, I am currently trying to write a program for my project and am
> trying to make the following syntax work:
>
>
> if y_1=y_2:
>     [y_1,y_2]=2
> elif y_1>y_2:
>     [y_1,y_2]=1

I think you want is

> if y_1 = y_2:
>     y_1 = y_2 = 2
> elif y_1>y_2:
>     y_1 = y_2 = 1

"[a,b] = x" essentially means "tmp = list(x); a = tmp[0]; b = tmp[1]"

> x=0
> for y_1 in [1..2]:
>     for y_2 in [1..y_1]:
>          x += [y_1,y_2]
> print x

What are you trying to do here? x is an integer, [y_1, y_2] is a list
of integers. It doesn't really make sense to add an integer to a list.

> The error messages I am getting is " TypeError:
> 'sage.rings.integer.Integer' object is not iterable ".
>
> When this code is fixed and does work, the answer would be x=5.
> Can anybody see where my code is going wrong please?
>
> Kind Regards
> Chappman
>
> --
> To post to this group, send email to sage-support@googlegroups.com
> To unsubscribe from this group, send email to 
> sage-support+unsubscr...@googlegroups.com
> For more options, visit this group at 
> http://groups.google.com/group/sage-support
> URL: http://www.sagemath.org

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

Reply via email to