For this exercise you will create a global flatten method. The method takes in any number of arguments and flattens them into a single array. If any of the arguments passed in are an array then the individual objects within the array will be flattened so that they exist at the same level as the other arguments. Any nested arrays, no matter how deep, should be flattened into the single array result.

The following are examples of how this function would be used and what the expected results would be:

```python
flatten(1, [2, 3], 4, 5, [6, [7]]) # returns [1, 2, 3, 4, 5, 6, 7]
flatten('a', ['b', 2], 3, None, [[4], ['c']]) # returns ['a', 'b', 2, 3, None, 4, 'c']
```

Difficulty: EASY
Starter code: def flatten(*args):
	

Solutions:
def flatten(*a):
	r = []
	for x in a:
		if isinstance(x, list):
			r.extend(flatten(*x))
		else:
			r.append(x)
	return r


def flatten(*args):
	return [x for a in args for x in (flatten(*a) if isinstance(a, list) else [a])]


def flatten(*args):

	def _flat(lst):
		for x in lst:
			if isinstance(x, list):
				yield from _flat(x)
			else:
				yield x
	return list(_flat(args))


def flatten(*args):
	result = []
	for arg in args:
		if type(arg) is list:
			result.extend(flatten(*arg))
		else:
			result.append(arg)
	return result


def flatten(*a):
	(r, s) = ([], [iter(a)])
	while s:
		it = s.pop()
		for v in it:
			if isinstance(v, list):
				s.extend((it, iter(v)))
				break
			else:
				r.append(v)
	return r


def flatten(*arr):
	inputlist = list(arr)
	while True:
		typelist = []
		for i in inputlist:
			typelist.append(type(i))
		if list in typelist:
			inputlist = takeoff(inputlist)
		else:
			return inputlist

def takeoff(inputlist):
	output = []
	for i in inputlist:
		if type(i) == list:
			output.extend(i)
		else:
			output.append(i)
	return output


def flatten(*elements):
	lst = list(elements)
	while any((isinstance(x, list) for x in lst)):
		for (i, x) in enumerate(lst):
			if isinstance(x, list):
				lst[i:i + 1] = x
	return lst


def flatten(*args):
	flattened_list = [arg for arg in args]
	result = []
	while any((isinstance(element, list) for element in flattened_list)):
		for element in flattened_list:
			if type(element) is list:
				for j in element:
					result.append(j)
			else:
				result.append(element)
		flattened_list = result[:]
		result.clear()
	return flattened_list


def flatten(*args):
	return [a for arg in args for a in (flatten(*arg) if type(arg) is list else [arg])]


def flatten(*args):
	return flat([], *args)

def flat(res, *args):
	for arg in args:
		if isinstance(arg, list):
			flat(res, *arg)
		else:
			res.append(arg)
	return res