assigning values to array element

Michael Peuser mpeuser at web.de
Wed Oct 15 02:24:56 EDT 2003


"Ben" <crescent_au at yahoo.com>
>
> This may sound easy but I'm having trouble assigning values to array
> element. My problem is as follows:
>
> m = ['Peter', 'Sam', 'Dave', 'Carl']
> for o in m:
>   # Here first o is 'Peter'.. I want to do something like this:
>   Peter = 10
>
>   # if i do %s %o = 10, it gives me error...
>
> How can I do it?

I think 'old stuff' is really appropriate here:

for index in xrange(len(m)):
    m[index]=10

Kindly
MichaelP






More information about the Python-list mailing list