1 | initial version |

As explained by @Luca, it is not a good idea to have indices as a substring of the name of your lists, but as indices (`list[i]`

makes more sense than `list_i`

).

Lists indices go from `0`

to `length-1`

, so if `a`

is big (or if the set of indices is sparse), you should better use a dictionary instead. For example, assume that the i^th element (more precisely the element whose key is `i`

) of your dictionary is the list `[i,i^2]`

, you can write:

```
sage: a = 10
sage: b = 20
sage: dict_number = {}
sage: for i in srange(a, b+1, 1):
....: dict_number[i] = [i, i^2]
```

Then you can call the 13^th element of your dictionary:

```
sage: dict_number[13]
[13, 169]
```

Note that the keys of your dictionary can be more than just numbers, for example they can be strings:

```
sage: dict_number['plop'] = [12,13]
sage: dict_number['plop']
[12, 13]
```

You can read more about python dictionaries here.

2 | No.2 Revision |

As explained by @Luca, it is not a good idea to have indices as a substring of the name of your lists, but as ~~indices (~~`list[i]`

`indices: `

.`list_number[i]`

makes more sense than

).list_number_i~~list_i~~

Lists indices go from `0`

to `length-1`

, so if `a`

is big (or if the set of indices is sparse), you ~~should better ~~can use a dictionary instead. For example, assume that the i^th element (more precisely the element whose key is `i`

) of your dictionary is the list `[i,i^2]`

, you can write:

```
sage: a = 10
sage: b = 20
sage: dict_number = {}
sage: for i in srange(a, b+1, 1):
....: dict_number[i] = [i, i^2]
```

Then you can call the 13^th element of your dictionary:

```
sage: dict_number[13]
[13, 169]
```

Note that the keys of your dictionary can be more than just numbers, for example they can be strings:

```
sage: dict_number['plop'] = [12,13]
sage: dict_number['plop']
[12, 13]
```

You can read more about python dictionaries here.

3 | No.3 Revision |

As explained by @Luca, it is not a good idea to have indices as a substring of the name of your lists, but as indices: `list_number[i]`

makes more sense than `list_number_i`

.

Lists indices go from `0`

to `length-1`

, so if `a`

is big (or if the set of indices is sparse), you can use a dictionary instead. For example, assume that the i^th element (more precisely the element whose key is `i`

) of your dictionary is the list `[i,i^2]`

, you can write:

```
sage: a = 10
sage: b = 20
sage: dict_number = {}
sage: for i in srange(a, b+1, 1):
....: dict_number[i] = [i, i^2]
```

Then you can call the ~~13^th ~~element of your ~~dictionary:~~dictionary whose key is 13:

```
sage: dict_number[13]
[13, 169]
```

Note that the keys of your dictionary can be more than just numbers, for example they can be strings:

```
sage: dict_number['plop'] = [12,13]
sage: dict_number['plop']
[12, 13]
```

You can read more about python dictionaries here.

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.