Question: How can i change image url parameters?

Example:

```
http://www.example.com/random1/random2/random3/nameofimage.jpg

```

In random will be random letters and numbers.

I don't have any idea how to do it, if you could help me I thank you

Answer: 
This is an excellent use case for a set. Remember, a + b == n <--> a == n-b.

Checking membership in a set is O(1). Thus, we can solve this with two iterations through our iterable. One to create the set, and one to check for our 'partner'. We can make sure to only return our pairs in the 'correct order' by making sure that our first item is smaller than the target // 2

```
def gen_pairs(iterable, target):
    iterable = set(iterable)
    for i in iterable:
        if target-i in iterable and i <= target // 2:
            yield i, target-i

```

Here's a brief example:

```
arr = [1,3,7,5]
print(list(gen_pairs(arr, 8)))

```

OUTPUT: `[(1, 7), (3, 5)]`

Note the following (deliberate) bug. Why does this happen? How would you fix this? (Hint - collections.Counter is your friend!)

```
arr2 = [4, 1, 7]
print(list(gen_pairs(arr2, 8)))
[(1, 7), (4, 4)]

```
The easiest way is to just ensure the second element always being later in the list than the first. Also, if you have a list, it is possible to loop over the elements, rather than their indices.

```
arr = [1,3,7]

for i, first in enumerate(arr):
    for second in arr[i+1:]:
        if first + second == 8:
            print('{} and {} is: yes'.format(first, second))

```