Question: ```
def ints(filename):
    a = []
    f = open(filename, "r")
    lines = f.readlines()
    f.close()
    for line in lines:
        numbers = line.split()
        for number in numbers:            
            a.append(int(number))
    return a

```

This is my function so far, I want to be able to read a file containing integers and characters like "x" and "b" etc and return a list of only the integers. At the moment the function can only deal with a file containing integers.

How can I modify this to exclude characters or letters?

Answer: 
This is my edit of your code, which performs as you expect it to.

```
  def ints(filename):
        """A function that takes the filename of a file as an input arguement, computs and returns a list of
        integers of all the numbers in the file."""
        a = []
        f = open(filename, "r")
        lines = f.readlines()
        f.close()
        for line in lines:
            for character in line:
                try:
                    a.append(int(character))
                except ValueError:
                    pass
        return a

```
Try/catch might help:

```
for thing in line.split():
    i_thing = None
    try:
        i_thing = int(thing)
    except ValueError:
        pass

    s_thing = None
    try:
        s_thing = str(thing)
    except:
        raise Exception("OH NOES!")

```

It's pretty ugly, but I haven't found a nicer way to do what you're trying to do.