import string


def remove_partsymbol(atom):
    """
    strips the part symbol like C1_4b from an atom name
    :param atom: 'C1_4b'
    :type atom: string

    >>> remove_partsymbol('C2_4b')
    'C2_4'
    >>> remove_partsymbol('C22_b')
    'C22'
    >>> remove_partsymbol('C_5')
    'C_5'
    >>> remove_partsymbol('SAME/SADI')
    'SAME/SADI'
    >>> remove_partsymbol('C22_4^b')
    'C22_4'
    >>> remove_partsymbol('C23^b')
    'C23'
    >>> remove_partsymbol('C24_0^b')
    'C24'
    >>> remove_partsymbol('C25_0b')
    'C25'
    """
    if '_' in atom or '^' in atom:
        if '^' in atom:
            # since SHELXL 2016/5, residue and part are devided by "^"
            name = atom.split('^')[0]
            if name.split('_')[-1] == '0':
                return name.split('_')[0]
            else:
                return name
        else:
            presuff = atom.split('_')
            prefix, suffix = presuff[0], presuff[-1].strip(string.ascii_letters)
        if not suffix:
            return prefix
        else:
            if suffix == '0':
                atom = prefix
            else:
                atom = prefix + '_' + suffix
    return atom