Error while concatenating lists in python
<p>I am working on an assignment for one of my classes at school where I need to concatenate two lists together.  I am using the code:</p>

<pre><code>flowers = ["rose", "bougainvillea", "yukka", "marigold", "daylily", "lily of the valley"]

thorny = flowers[0:3]
poisonous = flowers[-1]
dangerous = flowers[0:3] + flowers[-1]
</code></pre>

<p>I keep getting the error message:   </p>

<pre><code>dangerous = list(set(flowers[0:3] + flowers[-1]))   
TypeError: can only concatenate list (not "str") to list
</code></pre>

<p>I was wondering why this doesn't work.  Thanks!</p>

<p><code>flowers[0:3]</code> returns a list while <code>flowers[-1]</code> returns a string, so you are adding a string to a list. You can use <code>flowers[-1:]</code> to return a list instead.</p>

python