how prompt a user to for a file python code example

Example 1: how to write user input to a file in python

#Print User Input to A File
x = input("Enter blah : ")
y = open('C:\Users\USERNAME\Documents\Doc1.txt', 'w')
y.write(x)

#Convert text to binary and then write to file
x = input("Enter blah : ")
y = open('C:\Users\USERNAME\Documents\Doc1.txt', 'wb')
y.write(x)

Example 2: how to take user input and create a file in python

# Deleting a pre existing file : 

import os
os.remove(file.txt”)