import os

print(os.getcwd())

os.mkdir('cats')

flags = os.O_RDWR | os.O_CREAT
mode = 0o666
path = './cats/cats.txt'

file_d = os.open(path, flags, mode)

cats_dictionary = [
    {
        "breed": "Exotic Shorthair",
        "life span": "12-15 years",
        "origin": "United States",
    },
    {"breed": "Persian", "life span": "14-15 years", "origin": "Iran"},
    {
        "breed": "Maine Coon",
        "life span": "12-15 years",
        "origin": "United States"
    },
    {
        "breed": "Ragdoll",
        "life span": "12-17 years",
        "origin": "United States"
    },
    {"breed": "Abyssinian", "life span": "14-15 years", "origin": "Egypt"},
    {"breed": "Sphynx", "life span": "12-14 years", "origin": "Canada"},
    {"breed": "Siamese", "life span": " 12-14 years", "origin": "Thailand"},
    {
        "breed": "Oriental",
        "life span": "12-14 years",
        "origin": "United States"
    },
    {"breed": "Birman", "life span": "14-15 years", "origin": "France"},
    {"breed": "Siberian", "life span": "12-15 years", "origin": "Russia"},
]

catlist = 'Lists of Cat Breeds \n'
os.write(file_d, catlist.encode())
for line in cats_dictionary:
    breed = line['breed']
    span = line['life span']
    origin = line['origin']
    resb = '*** ' + breed + '\n'
    ress = 'Life span: ' + span + '\n'
    reso = 'Origin: ' + origin + '\n'
    result = resb + ress + reso
    print(result)
    os.write(file_d, result.encode())

catext = './cats/cats.txt'
readb = os.stat(catext)
size = str(readb.st_size) + ' bytes'

file_size = f'File size: {size}'
print(file_size)
os.write(file_d, file_size.encode())