Print word from list

Chris Angelico rosuav at gmail.com
Sat Aug 3 18:22:40 EDT 2013


On Sat, Aug 3, 2013 at 11:17 PM,  <eschneider92 at comcast.net> wrote:
> pie='apple keylime pecan meat pot cherry'
> pie.split()
>
> How can I print a word from the list other than this way:  print(pie[0:5])  ?

The split() method returns a list, it doesn't change the original string. Try:

pies = pie.split()
print(pie[2])

ChrisA



More information about the Python-list mailing list