It seems like you are working with paths and files so Python's pathlib might be helpful in this situation.
From your example, if /works/proj
is a known project area and you want to know the location of the file relative to that directory you can use the following:
from pathlib import Path
proj_root = Path('/works/proj')
xls_abs = Path("/works/proj/kod/resources/excel/words/tam.xls")
xls_rel = xls_abs.relative_to(proj_root)
print(xls_rel)
# kod/resources/excel/words/tam.xls
Or if it is specifically the word kod
you want to search for then you can split the path into parts and rejoin them from that index. e.g:
xls_parts = xls_abs.parts
kod_index = xls_parts.index('kod')
xls_rel = Path(*xls_parts[kod_index:])
print(xls_rel)
# kod/resources/excel/words/tam.xls