Add a comment before each line explaining what it's doing:
def filename_extension(file):
    parts = file.rpartition('.')
    if parts[0] != '' and parts[1] != '':
        return '.' + parts[-1].lower()
    else:
        return ''
system
prayek pankti se pehle ek tippanee joden ki yah kya kar rahaa he:
def fileName_extension (fil):
    bhaagon = file.rpartition ('.')
    yadi bhaagon [0]! = '' or bhaagon [1]! = '':
        waapas karnaa '.'+ bhaag [-1] .lower ()
    anya:
        waapas karnaa ''
user
def fileName_extension (fil):
    # fil naam ko ek tapal main vibhajit karen, jisamen '' ', string' ke antim udhaaharan tak sab kuch hota he. ', or' '' ke antim udhaaharan ke baad sab kuch.
    bhaagon = file.rpartition ('.')
    # agar '.'vastav main fil naam main maujuud he or iskaa ekmaatr udhaaharan fil naam kii shuruyaat main nahin he:
    yadi bhaagon [0]! = '' or bhaagon [1]! = ':
        # lauten '.'nichle string dwaara peechha kiya gaya he jo antim kaa anusaran karata he. 'fil naam main
        waapas karnaa '.'+ bhaag [-1] .lower ()
    anya:
        # ek khaali string lauten
        waapas karnaa ''
assistant
<|system|>
</s>
<|user|>
prayek pankti se pehle ek tippanee joden ki yah kya kar rahaa he:
def fileName_extension (fil):
    bhaagon = file.rpartition ('.')
    yadi bhaagon [0]! = '' or bhaagon [1]! = '':
        waapas karnaa '.'+ bhaag [-1] .lower ()
    anya:
        waapas karnaa ''</s>
<|assistant|>
def fileName_extension (fil):
    # fil naam ko ek tapal main vibhajit karen, jisamen '' ', string' ke antim udhaaharan tak sab kuch hota he. ', or' '' ke antim udhaaharan ke baad sab kuch.
    bhaagon = file.rpartition ('.')
    # agar '.'vastav main fil naam main maujuud he or iskaa ekmaatr udhaaharan fil naam kii shuruyaat main nahin he:
    yadi bhaagon [0]! = '' or bhaagon [1]! = ':
        # lauten '.'nichle string dwaara peechha kiya gaya he jo antim kaa anusaran karata he. 'fil naam main
        waapas karnaa '.'+ bhaag [-1] .lower ()
    anya:
        # ek khaali string lauten
        waapas karnaa ''</s>
