We can also do this question without split method(Here is link:https://www.geeksforgeeks.org/simplify-directory-path-unix-like/)
#My method using split function
L=(A.split("/"))
i=0
stack=[]
while(i<len(L)):
while(L[i]==" "):
i+=1
if(L[i].isalpha()):
stack.append(L[i])
if(L[i]==".."):
if(stack):
stack.pop()
i+=1
if(len(stack)==0):
return("/")
else:
res=""
for i in stack:
res+="/"+i
return(res)