Your question is Absolute and Relative Path Normalization. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Given a string containing an absolute or relative path, return the correct normalized path (for example, ../var../logs should give ../logs). The function accepts a string path and returns a normalized string, removing redundant separators and . components, resolving .., and ignoring components that contain .. without being exactly ... For example, /a/./b/../c/ becomes /a/c, while a/../../b becomes ../b.
//.. performs parent-directory traversal/ as the separatordef normalize_path(path):