makeTextFile.py
>>> import os >>> ls = os.linesep >>> # get filename >>> while True: fname = input('Enter file name: ') if os.path.exists(fname): print("*** ERROR: '%s' already exists" % fname) else: break Enter file name: dinghong *** ERROR: 'dinghong' already exists Enter file name: hongding >>> # get file content (text) lines >>> all = [] >>> print ("\nEnter lines ('.' by itself to quit).\n") Enter lines ('.' by itself to quit). >>> # loop until user terminates input >>> while True: entry = input('> ') if entry == '.': break else: all.append(entry) >
>
> .
>>>