>#open file and read last names
>filename = input('name file')
>file = open(filename, 'r')
>names_list = file.readlines()
>file.close()
>#open a file for saving passwords
>outfile_name = input('Save passwords')
>outfile = open(outfile_name, 'a')
>
>
>#create a password for each name in list
>import random, string
>name = ('')
>for name in names_list:
> name_prefix = name[0:2]
> number = random.randrange(100,999)
> name_prefix = str.upper(name_prefix)
> password = name_prefix + str(number)
> whole_line = (password)
> print (password)
> outfile_name.write(whole_line)
> outfile_name.close()
>
> print (password)
>
>error
>Traceback (most recent call last):
> File "C:\Documents and Settings\Gary\Desktop\python\bembry\pa2.i.py",
line 21, in <module>
> outfile_name.write(whole_line)
>AttributeError: 'str' object has no attribute 'write'
You're trying to output to the output filename string rather that the
output file you opened with that filename.
Cheers,
Drea
--
http://mail.python.org/mailman/listinfo/python-list