# Print out 'File is empty!' if nodata.txt is empty if os.path.getsize('nodata.txt') == 0: print("File is empty!")
If the nodata.txt file would be empty, the output would be:
'File is empty'
If nodata.txt had some content, there will not be any output printed out.
You can try this yourself below. The current directory of the embedded Python editor below has two files inside, an empty nodata.txt file, and a non-empty data.txt file. Try changing 'nodata.txt' to 'data.txt' in the code below and run the code. You will get a different output this time.
Learn Flask development and learn to build cool apps with our premium Python course on Udemy.
We will keep you Python-motivated if you subscribe below.