r is placed before filename to prevent the characters in filename string to be treated as special character.
For example, if there is \temp in the file address, then \t is treated as the tab character and error is
raised of invalid address. The r makes the string raw, that is, it tells that the string is without any special characters.
The r can be ignored if the file is in same directory and address is not being placed.
# Open function to open the file "MyFile1.txt" (same directory) in read mode and store its reference in the variable file1
file1 = open("MyFile.txt", "r")
#and "MyFile2.txt" in D:\Text in file2
file2 = open(r"D:\Text\MyFile2.txt", "r")
We can ignore starting r in our script also since the file is present in same location as the script