What is wrong with my code?

Chris Rebert clp2 at rebertia.com
Sun Oct 23 06:08:33 EDT 2011


On Sun, Oct 23, 2011 at 3:03 AM, apometron
<apometron.listas.cinco at gmail.com> wrote:
> import os
> nome = sys.argv[1]

You did not `import sys`, so you'll get a NameError there.

> final = nome
> for i in nome:
>    print i
>    if nome[i] = "_":
>        final[i] = " "

Strings aren't mutable in Python; you can't assign to slices of them.
So you'll get a TypeError on the previous line.

Cheers,
Chris



More information about the Python-list mailing list