def padded_text(word, max_length, centered):
    """
    Returns padded text with spaces (centered or not)
    """

    word_str = str(word)
    len_word = len(word_str)

    if centered:
        len_pad = max_length - len_word
        if len_pad % 2 == 0:
            pad = int(len_pad / 2)
            l, r = pad, pad
        else:
            l = int(len_pad / 2)
            r = len_pad - l
        return (" " * l) + word_str + (" " * r)
    return " " + word_str + " " * (max_length - len_word - 1)