Question: I am trying to write a recursive function which returns a copy of a list where neighbouring elements have been swapped. For example, swapElements([2, 3, 4, 9]) would return [3, 2, 9, 4].  

This is my code as of now:

```
def swapElements(mylist):
    if len(mylist) == 1:
        pass
    if len(mylist) == 2:
        mylist[0], mylist[1] = mylist[1], mylist[0]
    else:
        mylist[0], mylist[1] = mylist[1], mylist[0]
        swapElements(mylist[2:])
    return mylist

```

When I run this function it only returns the list with the first two elements swapped, does anyone know why this function is not swapping any other elements other than the first two and how I could fix it?

Answer: 
> 
> Comparing two slices for missing element
> 
> 
> I have two slices: `a []string`, `b []string`. `b` contains all the same
> elements as `a` plus an extra.
> 
> 
> 

For example,

```
package main

import (
    "fmt"
)

func missing(a, b []string) string {
    ma := make(map[string]bool, len(a))
    for _, ka := range a {
        ma[ka] = true
    }
    for _, kb := range b {
        if !ma[kb] {
            return kb
        }
    }
    return ""
}

func main() {
    a := []string{"a", "b", "c", "d", "e", "f", "g"}
    b := []string{"a", "1sdsdfsdfsdsdf", "c", "d", "e", "f", "g", "b"}
    fmt.Println(missing(a, b))
}

```

Output:

```
1sdsdfsdfsdsdf

```
```
/*
An example of how to find the difference between two slices.
This example uses empty struct (0 bytes) for map values.
*/

package main

import (
    "fmt"
)

// empty struct (0 bytes)
type void struct{}

// missing compares two slices and returns slice of differences
func missing(a, b []string) []string {
    // create map with length of the 'a' slice
    ma := make(map[string]void, len(a))
    diffs := []string{}
    // Convert first slice to map with empty struct (0 bytes)
    for _, ka := range a {
        ma[ka] = void{}
    }
    // find missing values in a
    for _, kb := range b {
        if _, ok := ma[kb]; !ok {
            diffs = append(diffs, kb)
        }
    }
    return diffs
}

func main() {
    a := []string{"a", "b", "c", "d", "e", "f", "g"}
    b := []string{"a", "c", "d", "e", "f", "g", "b"}
    c := []string{"a", "b", "x", "y", "z"}
    fmt.Println("a and b diffs", missing(a, b))
    fmt.Println("a and c diffs", missing(a, c))
}

```

Output 

```
a and b diffs []
a and c diffs [x y z]

```