Feb-15-2017, 07:31 PM
I have to copy already created text file, Layer_Name.txt , so new copied file has to be renamed with user input initials (IN_Layer_Name.txt)
If the user does not enter a value then repeat the prompt until they do so.
The code that creates the copy has to be in a separate custom function that is created. The values for the name of the file to copy and the name of the file to create (i.e. the output) must be passed to custom function.
This is what I have done but it doesn`t work:
Thank you very much for your help!
If the user does not enter a value then repeat the prompt until they do so.
The code that creates the copy has to be in a separate custom function that is created. The values for the name of the file to copy and the name of the file to create (i.e. the output) must be passed to custom function.
This is what I have done but it doesn`t work:
import os root_path = r"C:\ABC" user_input = None def initials(): print() while(not user_input): user_input = raw_input("Please enter your initials: ") initials(user_input) from shutil import copyfile initials = userinput copyfile('Layer_Names.txt', '%s_Layer_Names.txt' %initials) break print 'Copy file has been created'
Thank you very much for your help!