PYTHON 35 You must have a function named print data which si
PYTHON 3.5
You must have a function named print data which simply prints the contents of the text file
data file.txt as one big string. There is no input (even though it accesses the file), and nothing
is returned. You can assume that the text file has been created before calling this function. This
function is included so the user can check that the text file has the correct text in it. This function and the previous function should both be pretty short, maybe 4 lines.
Solution
I have written a function in python which will read a file from the file path. You have to just change the file path where your file is placed.
f = open(file_path, \'r\') will read the file from the file_path given. Now you have to just print the contents of \'f\'.
This can be done using print f.read(). This will print the output in the stdout.
Lastly you need to close the connection using f.close()
Whole code :
 def print_data():
    #Your file path
    file_path = \"/home/abhinav/Desktop/important\"
    f = open(file_path, \'r\')
    print f.read()
    f.close()  
print_data()

