Answer:
The program in Python is as follows:
fname1 = input("Filepath 1: ").lower()
fname2 = input("Filepath 2: ").lower()
fname3 = input("Filepath 3: ").lower()
f1dir = ""; f2dir = ""; f3dir = ""
fnamesplit = fname1.split("/")
for i in range(len(fnamesplit)-1):
f1dir+=fnamesplit[i]+"/"
fnamesplit = fname2.split("/")
for i in range(len(fnamesplit)-1):
f2dir+=fnamesplit[i]+"/"
fnamesplit = fname3.split("/")
for i in range(len(fnamesplit)-1):
f3dir+=fnamesplit[i]+"/"
if f1dir == f2dir == f3dir:
print("Files are in the same folder")
else:
print("Files are in the different folder")
Explanation:
The next three lines get the file path of the three files
<em>fname1 = input("Filepath 1: ").lower()</em>
<em>fname2 = input("Filepath 2: ").lower()</em>
<em>fname3 = input("Filepath 3: ").lower()</em>
This initializes the directory of the three files to an empty string
f1dir = ""; f2dir = ""; f3dir = ""
This splits file name 1 by "/"
fnamesplit = fname1.split("/")
This iteration gets the directory of file 1 (leaving out the file name)
<em>for i in range(len(fnamesplit)-1):</em>
<em> f1dir+=fnamesplit[i]+"/"</em>
This splits file name 2 by "/"
fnamesplit = fname2.split("/")
This iteration gets the directory of file 2 (leaving out the file name)
<em>for i in range(len(fnamesplit)-1):</em>
<em> f2dir+=fnamesplit[i]+"/"</em>
This splits file name 3 by "/"
fnamesplit = fname3.split("/")
This iteration gets the directory of file 3 (leaving out the file name)
<em>for i in range(len(fnamesplit)-1):</em>
<em> f3dir+=fnamesplit[i]+"/"</em>
This checks if the file directories hold the same value
This is executed, if yes
<em>if f1dir == f2dir == f3dir:</em>
<em> print("Files are in the same folder")</em>
This is executed, if otherwise
<em>else:</em>
<em> print("Files are in the different folder")</em>