I'm trying to create_python_script function that creates a new python script in the current working directory, adds the line of comments to it declared by the 'comments' variable, and returns the size of the new file. The output I get is 0 but should be 31. Not sure what I'm doing wrong.
import os
def create_python_script(filename):
comments = "# Start of a new Python program"
with open("program.py", "w") as file:
filesize = os.path.getsize("/home/program.py")
return(filesize)
print(create_python_script("program.py"))
"program.py"to zero size, then queries the file size (its 0) and returns that. Did you mean to write thecommentsto the file at all?