Saturday, 14 September 2013

Assigning to a new list just the last object of another list - Python

Assigning to a new list just the last object of another list - Python

OK, in Python I have list:
flowers = ["rose", "bougainvillea", "yucca", "marigold", "daylilly",
"lilley of the valley"]
Now, I want to assign just the last object of list flowers to a new list
called poisonous.
I tried:
poisonous=flowers[-1]
However this statement makes poisonous a string instead of a list.

No comments:

Post a Comment