Use range(n-1) instead of range [n-1].

*Christophe BAL*
*Enseignant de mathématiques en Lycée **et développeur Python amateur*
*---*
*French math teacher in a "Lycée" **and **Python **amateur developer*

2015-06-04 23:44 GMT+02:00 Phoenix <anirbit.mukher...@gmail.com>:

>
> I am trying to define a function "elem" which will create me a list of
> length n which has 1 at the i^th position.
>
> def elem (i,n):
>   A = []
>   for k in range [n-1]:
>       if k != i:
>           A.append([0])
>       if k == i:
>           A.append([1])
>
>   return A
>
> elem (1,5)
>
> Why does the above not work?
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Reply via email to