Hi, everyone,

I want to create a sparse matrix, so I need to create a dict first. I try to use `dict.fromkeys()` to do it, which like following:

```
sage: keys = [(0,1),(1,2)] # the length of keys maybe very long
sage: values = [0,1] # values have the same length as keys
sage: d = dict.fromkeys(keys,values)
sage: d
{(0, 1): [0, 1], (1, 2): [0, 1]}
```
But the result is not what I want, and I want to get this:

```
{(0,1):0,(1,2):1}
```

Does there exist other way to do this? Hope to get your help, thanks very much.

Best

Huayi





--
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