Question: I need to write a function that will list n amount of numbers that are divisible by m. So if I list the function divisibility(10,2) it will list the first 10 numbers divisible by 2. This is in Python 3. Any basic structures that I can manipulate would be helpful. Brand new programmer, so all insight will much appreciated! Thanks!

Answer: 
If you have the entire file read into memory, you can search multiple lines at once:

```
$file =~ m/^\s*(\d+\.\d+\s+\d+\s+ng)\n\s*(\d+\.\d+\s+\d+\s+b)/ms ;

```

Otherwise you end up writing some kind of state machine.

If the endings are going to be changing, you can even use variables for them:

```
my $end1= 'ng' ;
my $end2= 'b' ;
$file =~ m/^\s*(\d+\.\d+\s+\d+\s+$end1)\n\s*(\d+\.\d+\s+\d+\s+$end2)/ms ;

```

And if you have to deal with DOS newlines, adjust to suit:

```
$file =~ m/^\s*(\d+\.\d+\s+\d+\s+$end1)\r*\n\s*(\d+\.\d+\s+\d+\s+$end2)/ms ;

```
As always with this kind of problem, either read the entire file into memory, or keep a copy of the preceding lines you might need in memory.

```
my $prev = <>;
if (defined($prev)) {
   while (my $this = <>) {
      if ($this =~ /\sb$/ && $prev =~ /\sng$/) {
         # Do whatever you want with the two lines here.
         print($prev);
         print($this);
      }

      $prev = $this;
   }
}

```