Question: Say I have two arrays of equal length, one of type x and the other of type y, with x being half the size in memory of y. If I generated 2 objects, one of type x and the other of type y, and checked to see if their respective arrays contained them, would both operations take, on average, the same time?  

Can this time be improved by using another (ordered) data structure?

Answer: 
Your binary search code is (mostly) ok, but there are a couple of problems in your code that reads in the list of countries.

Your file opening & reading code is strange. It's like you've combined two different approaches to reading data, so you are opening the file multiple times.

Fortunately, the effects of these lines:

```
with open(filename) as aFile:
    countries = aFile.read()

```

don't affect the output of the `readCountries` function because you don't do anything else with `countries`.

Also, in the description of your assignment it says to "strip the data as appropriate. Numbers should be converted to their correct types", which your code doesn't do. And as my hint above implied, that means the country names in your list still had the commas attached to them, so the binary search couldn't find them (unless you included the comma in the search name).

Anyway, here's a cleaned up version that's designed to run on Python 2.6 or later.

```
from __future__ import print_function

def readCountries(filename):
    countryList = []
    with open(filename) as aFile:
        for line in aFile:
            line = line.strip().split()
            #Remove anny trailing commas from each field
            line = [s.rstrip(',') for s in line]
            #Convert area to float and population to int
            line = [line[0], float(line[1]), int(line[2])]
            #print line
            countryList.append(line)
    return countryList

countryList = readCountries("countries.txt")

def printCountry(name):
    lo, hi = 0, len(countryList) - 1
    while lo <= hi:
        mid = lo + (hi - lo) // 2
        country = countryList[mid]
        test_name = country[0]
        if name > test_name:
            lo = mid + 1
        elif name < test_name:
            hi = mid - 1
        else:
            print('  {0}, Area: {1}, Population: {2}'.format(*country))
            break
    else:
        print("  I'm sorry, could not find {0} in the country list.".format(name))

#tests
printCountry("Canada")
printCountry("Winterfell")

print('- ' * 20)

#make sure we can find the first & last countries.
printCountry("Afghanistan")
printCountry("Nowhere")

```

Here's the data file I ran it on:

**countries.txt**

```none
Afghanistan,    647500.0,   25500100
Albania,    28748.0,    2821977
Algeria,    2381740.0,  38700000
Canada,     9976140.0,  35295770
Nowhere,    1000.0      2345678

```

And this is the output it produced:

```none
  Canada, Area: 9976140.0, Population: 35295770
  I'm sorry, could not find Winterfell in the country list.
- - - - - - - - - - - - - - - - - - - - 
  Afghanistan, Area: 647500.0, Population: 25500100
  Nowhere, Area: 1000.0, Population: 2345678

```
Ensure that the list is sorted before binary searching on it with:

```
countryList.sort()

```