Taking into consideration the [3.5 edition rules](http://www.dandwiki.com/wiki/SRD:Ability_Scores#Table:_Ability_Modifiers_and_Bonus_Spells), your goal is to build a function that takes an ability score (worry not about validation: it is always going to be a non negative integer), will return:

* attribute modifier, as indicated on the table of the above link;
* maximum spell level for the spells you can cast (-1 for no spells at all) with that score;
* the eventual extra spells you might get (as an array/list, with elements representing extra spells for 1st, 2nd,... spell level in order; empty array for no extra spells).

The result needs to be an object (associative array in PHP), as shown in the examples:

```python
char_attribute(0) == {"modifier": 0, "maximum_spell_level": -1, "extra_spells": []}
char_attribute(1) == {"modifier": -5, "maximum_spell_level": -1, "extra_spells": []}
char_attribute(5) == {"modifier": -3, "maximum_spell_level": -1, "extra_spells": []}
char_attribute(10) == {"modifier": 0, "maximum_spell_level": 0, "extra_spells": []}
char_attribute(20) == {"modifier": +5, "maximum_spell_level": 9, "extra_spells": [2,1,1,1,1]}
```

*Note: I didn't explain things in detail and just pointed out to the table on purpose, as my goal is also to train the pattern recognition skills of whoever is going to take this challenges, so do not complain about a summary description. Thanks :)*

In the same series:

* [D&D Character generator #1: attribute modifiers and spells](https://www.codewars.com/kata/d-and-d-character-generator-number-1-attribute-modifiers-and-spells/)
* [D&D Character generator #2: psion power points](https://www.codewars.com/kata/d-and-d-character-generator-number-2-psion-power-points/)
* [D&D Character generator #3: carrying capacity](https://www.codewars.com/kata/d-and-d-character-generator-number-3-carrying-capacity/)

Difficulty: introductory

Starter code:

def char_attribute(score):
	

Solutions:
def char_attribute(score):
    return ({"modifier": 0, "maximum_spell_level": -1, "extra_spells": []} if not score
        else {"modifier":            score//2-5,
              "maximum_spell_level": -1 if score//2-5 < 0 else min(9, score -10) ,
              "extra_spells":        [1+n//4 for n in range(score//2-5)][::-1][:9] })

def char_attribute(score):
    
    result = {}
    
    #modifier
    result["modifier"] = 0 if score == 0 else score //2 - 5
    
    #maximum_spell_level
    result["maximum_spell_level"] = -1 if score < 10 else min(9, score -10)
    
    #extra_spells         
    result["extra_spells"] = [1 + n//4 for n in range(result["modifier"])][::-1][:9]
    
    return result

def char_attribute(score):
    modifier = score and (score - 10) // 2
    extra_spells = [i//4 for i in reversed(range(score//2-10, score//2-1)) if i > 3]
    maximum_spell_level = min(score-10, 9) if score >= 10 else -1
    return {
        'modifier': modifier,
        'maximum_spell_level': maximum_spell_level,
        'extra_spells': extra_spells,
    }

from math import ceil;char_attribute=lambda n: (lambda m: {"modifier": n and m, "maximum_spell_level": -1 if n<10 else min([n-10,9]), "extra_spells": [e for e in [(lambda s: s if s>0 else None)(ceil((m-i)/4)) for i in range(9)] if e!=None]})(n//2-5 if n else -1)

def char_attribute(score):
    modifier=(score-10)//2 if score>0 else 0
    m_spell=min(max(-1,score-10),9)
    e_spells=[]
    x=0
    for i in range((score-10)//2):
        if i%4==0:
            x+=1
        e_spells.insert(0,x)
    return {'modifier':modifier,'maximum_spell_level':m_spell,'extra_spells':e_spells[:9]}

def char_attribute(score):
    if score > 0:
        mod = score//2 - 5
    else:
        mod = 0
    
    if score > 11:
        bonus_spells = [max(0,(score - i)//8) for i in range(4,21,2)]
        while min(bonus_spells) == 0:
            bonus_spells.pop()
    else:
        bonus_spells= []
    
    max_spell = min(9, max(-1,score-10))
    
    
    return {"modifier": mod, "maximum_spell_level": max_spell, "extra_spells":bonus_spells} 

def char_attribute(score):
    modifier = 0 if score == 0 else score //2 - 5    
    maximum_spell_level = -1 if score < 10 else min(9, score -10)    
    extra_spells = [1 + n//4 for n in range(modifier)][::-1][:9]    
    return {"modifier": modifier, "maximum_spell_level": maximum_spell_level, "extra_spells": extra_spells}

points = []
for x in range(1, 200): 
    points.extend([x]*4)
points = points[::-1]

def char_attribute(score):
    print(score)
    mod = (-5 + score//2) if score else score
    max_spell = -1 if score < 10 else 0 if score==10 else 9
    extra = points[-mod:][:9] if mod > 0 else []
    return {"modifier": mod, "maximum_spell_level": max_spell, "extra_spells": extra}

def char_attribute(score):
    return {'modifier': 0, 'maximum_spell_level': -1, 'extra_spells': []} if score == 0 else (
        {'modifier': score//2-5,
        'maximum_spell_level': -1 if score//2-5 < 0 else min(9, score -10),
        'extra_spells': [i//4 + 1 for i in range(score//2-5)][-1:-10:-1]
        })

def char_attribute(score):
    attributes = {"modifier": 0, "maximum_spell_level": -1, "extra_spells": []}
    if score == 0:
        return attributes
    modifier = score // 2 - 5
    attributes['modifier'] = modifier
    if modifier < 0:
        return attributes
    else:
        attributes['maximum_spell_level'] = min(9, score-10)
        extra_spells = []
        for i in range(min(9, modifier)):
            extra = (modifier - 1 - i) // 4
            extra_spells.append(1 + extra)
        attributes['extra_spells'].extend(extra_spells)
        return attributes