# Storing Collections of Data Using Lists

2. a. `kingdoms[-6]`
b. `kingdoms[-1]`
c. `kingdoms[-6:-3]`
d. `kingdoms[-4:-1]`
e. `kingdoms[-2:]`
f. `kingdoms[-1:-2]` (many other solutions)

4. a. `ids.remove(3382)`
b. `ids.index(9362)`
c. `ids.insert(ids.index(9362) + 1, 4499)`
d. `ids = ids + [5566, 1830]` or:

```ids.append(5566)
ids.append(1830)
```
e. ```ids.reverse() f. <code>ids.sort() 6. a. <code>temps = [25.2, 16.8, 31.4, 23.9, 28, 22.5, 19.6]</code><br/> b. <code>temps.sort()</code><br/> c. <pre> cool_temps = temps[0:2] warm_temps = temps[2:] </pre> d. <code>temps_in_celsius = cool_temps + warm_temps</code><br/> 8. <pre> def is_longer(L1, L2): """ (list, list) -> bool Return True if and only if the length of L1 is longer than the length of L2. >>> is_longer([1, 2, 3], [4, 5]) True >>> is_longer(['abcdef'], ['ab', 'cd', 'ef']) False >>> is_longer(['a', 'b', 'c'], [1, 2, 3]) False """ return len(L1) > len(L2) </pre> 10. a. <code>units[0]</code><br/> b. <code>units[-1]</code> or <code>units[1]</code><br/> c. <code>units[0][0]</code><br/> d. <code>units[1][0]</code><br/> e. <code>units[0][1:]</code><br/> f. <code>units[1][0:2]</code><br/> ```
``` ```
``` ```
``` Quick links PragProg Home Wiki Top Level Playtime exercises from AWDwR Changes to Rails since the 3rd ed Notes How to Edit Pages Page History V3: Jason Montojo [11 months ago] V2: Jason Montojo [about 1 year ago] V1: Jason Montojo [about 1 year ago] Recent Changes ```
``` Home | About Us | Connect! | Write For Us | Privacy Policy | Security | Terms of Use | Credits | Contact Us The Pragmatic Bookshelf™ is an imprint of The Pragmatic Programmers, LLC. Copyright © 1999–2014 The Pragmatic Programmers, LLC. All Rights Reserved. setTimeout(function(){var a=document.createElement("script"); var b=document.getElementsByTagName("script")[0]; a.src=document.location.protocol+"//dnn506yrbagrg.cloudfront.net/pages/scripts/0021/7977.js?"+Math.floor(new Date().getTime()/3600000); a.async=true;a.type="text/javascript";b.parentNode.insertBefore(a,b)}, 1); ```
``` ```
``` ```