## Fall 2006 Midterm 2 Review: Address Book

This is impossible....I really don't understand at all...
Stacy Schwaiger
 The function is not that long, it can be written under 10 lines of code. First you need to open a file, read and store all the contents and then close it. After that, you need to split the text into seperate lines. Then, you need a for loop to search for the word, and if you find it, then jREMOVEDt print out that line. - Bobby Mathew

I'm guessing the key would be splitting on the "\n" and then searching for the string containing the name at the beginning of each item in the list.

```def lookup(who):
file.close
seperatedlist = []
x = 0
for person in seperatedlist:
if person[0].find(who) <> -1:
print person[0],":",person[1],":",person[2],":",person[3]
x = x + 1
if x == 0:
```

I split the lines up by colons, so it would only search the names. So, can you turn a list back into a string?
```def phone(who):
file.close
seperatedlist = []
x = 0
for person in seperatedlist:
if person[0].find(who) <> -1:
print person[3]
x = x + 1
if x == 0:
```

Student4291

That number is not Charlie REMOVEDs. Its Craig Hightowers. I was dissapointed.

Here's the right answer to the phone function. - Bobby Mathew
```def phone(string):
file.close()
lines = contents.split("\n")

for i in lines:
if i.find(string) != -1:
lastColon = i.rfind(":")
print i[lastColon+1:]
return