You are the Dungeon Master for a public DnD game at your local comic shop and recently you've had some trouble keeping your players' info neat and organized so you've decided to write a bit of code to help keep them sorted!

The goal of this code is to create an array of objects that stores a player's name and contact number from a given string.

The method should return an empty array if the argument passed is an empty string or `nil`/`None`/`null`.

## Examples

```ruby 
player_manager("John Doe, 8167238327, Jane Doe, 8163723827") returns [{player: "John Doe", contact: 8167238327}, {player: "Jane Doe", contact: 8163723827}]
player_manager(nil) returns []
player_manager("") returns []
```
```python
player_manager("John Doe, 8167238327, Jane Doe, 8163723827") returns [{"player": "John Doe", "contact": 8167238327}, {"player": "Jane Doe", "contact": 8163723827}]
player_manager(None) returns []
player_manager("")   returns []
```
```
playerManager("John Doe, 8167238327, Jane Doe, 8163723827") returns [{player: "John Doe", contact: 8167238327}, {player: "Jane Doe", contact: 8163723827}]
playerManager(null) returns []
playerManager("")   returns []
```

Have at thee!

Source: codewars | Difficulty: EASY
Tags: Data structures

Starter code: def player_manager(players):
	

Solutions:
import re

def player_manager(players):
	return players and [{'player': who, 'contact': int(num)} for (who, num) in re.findall('(.+?), (\\d+)(?:, )?', players)] or []


def player_manager(players):
	return [{'player': a, 'contact': int(b)} for (a, b) in zip(*[iter(players.split(', '))] * 2)] if players else []


def player_manager(players):
	if not players:
		return []
	lst = players.split(', ')
	return [{'player': name, 'contact': int(num)} for (name, num) in zip(lst[::2], lst[1::2])]


def player_manager(plrs):
	if not plrs:
		return []
	output = []
	(contact, player) = (plrs.split(', ')[1::2], plrs.split(', ')[::2])
	for x in range(len(contact)):
		output.append({'player': player[x], 'contact': int(contact[x])})
	return output


def player_manager(players):
	return [{'player': p.strip(), 'contact': int(c)} for (p, c) in zip(players.split(',')[::2], players.split(',')[1::2])] if players else []


import re

def player_manager(players):
	manager = []
	if players:
		players_list = re.findall('(?P<name>[a-zA-Z ]+), (?P<number>[0-9]+)', players)
		for (name, number) in players_list:
			manager.append({'player': name.strip(), 'contact': int(number)})
	return manager


def player_manager(players):
	result = []
	if not players:
		return []
	players = players.split(', ')
	for (i, x) in enumerate(players):
		if i % 2 == 0:
			result.append({})
			result[-1]['player'] = x
		else:
			result[-1]['contact'] = int(x)
	return result


def player_manager(players):
	if not players:
		return []
	players = players.split(', ')
	return [{'player': player, 'contact': int(contact)} for (player, contact) in zip(players[::2], players[1::2])]


def player_manager(players):
	if not players:
		return []
	p = players.split(', ')
	return [{'player': p[i], 'contact': int(p[i + 1])} for i in range(0, len(p) - 1, 2)]