[Tutor] Program

Corey Richardson kb1pkl at aim.com
Wed May 18 15:13:37 CEST 2011


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 05/18/2011 09:05 AM, Johnson Tran wrote:
> Thanks for the reply.
> 
> So to append a word is it suppose to look kind of like:
> 
> word=raw_input("Name #1: ")
>     word.append(words)
> 
> I keep getting error message:
> 
> Traceback (most recent call last):
>   File "/Users/JT/Desktop/pythonfinal", line 23, in <module>
>     CollectNames()
>   File "/Users/JT/Desktop/pythonfinal", line 7, in CollectNames
>     word.append(words)
> AttributeError: 'str' object has no attribute 'append'

Yes, because append belongs to list, and not str!
http://docs.python.org/tutorial/datastructures.html#more-on-lists

words = [
word = raw_input("Name #1: ")
words.append(word)

Keep in mind the rest of the email I sent, that part was one of the
least important (albeit fundamental).
- -- 
Corey Richardson
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iQEcBAEBAgAGBQJN08YBAAoJEAFAbo/KNFvpuSwH/jTqUncnANaRmlkJ3Mgd9C6k
QeGEduLfnxT5d0m6DIil7k9q8UKBgrrOE8MKbfanp0f/QIWFn7g4M8WAoNASUF26
Bb0sHuzCjAoEL3Gbf2nOejhBlAPCos4ReveDAysiSwJ4pe8hOQOzxQ73apNq8v1W
U8x0/X0JL5J6Cw/g4mEWd/Be2rYiQdL0xchpRB+9m6ATCTfo99g5VDR4kuB8T0Mi
wbfq/jEQZbKCWInwCHuD7n7438zUJad4MvNPPlBnrQDb76MzN4sU4ZXnKjRvYdsN
Z/fJKy40MWUtD/6Lw8fHhIVdtWFo0k6xM3bUjcPIYfRdHXHvX8NwEwyw3704YAY=
=SYly
-----END PGP SIGNATURE-----


More information about the Tutor mailing list