Как мне вывести «YES»?
...
if len(name) != 0:
    print('NO')
else:
    print('YES')
Я бы решил так:name1 = 'BABBONATALE'
name2 = 'FATHERCHRISTMAS'
letters = 'BABCHRISTMASBONATALLEFATHER'
name = name1 + name2
for letter in letters:
    if letter in name:
        name = name.replace(letter, '', 1)
    else:
        name = 'x'
        break
if len(name) != 0:
    print('NO')
else:
    print('YES')
А ещё лучше так:name1 = 'SANTACLAUS'
name2 = 'DEDMOROZ'
letters = 'SANTAMOROZDEDCLAUS'
if sorted(name1 + name2) != sorted(letters):
    print('NO')
else:
    print('YES')
Интересно было решатьguest = 'SANTACLAUS'
host = 'DEDMOROZ'
dic = 'SANTAMOROZDEDCLAUS'
sum_name = guest + host

a = 0
dic = list(dic)
c = 0

for i in sum_name:
    for j in range(len(dic)):
        if i == dic[j]:
            dic[j] = ''
            a = 1
            break
    if a == 0:
        c = 1
        print('no')
        break
if c == 0:
    dic = "".join(dic)
    if len(dic) != 0:
        print('no')
    else:
        print('yes')