import ast


def guess_type(string):
    """
    Guess the type of a value given as string and return it accordingly.

    Parameters
    ----------
    string : str
        given string containing the value
    """
    string = str(string)
    try:
        value = ast.literal_eval(string)
    except Exception:  # SyntaxError or ValueError
        return string
    else:
        return value