Python converting text file to all caps
Question: I'm new to python, and I'm trying to figure out how to write a program that
prompts the user for the name of a text file, converts the contents of the
text file to all caps, and then saves it as a new file.


Answer: 
    import os
    
    
    def main():
        fp = raw_input('Filename: ')
        if fp and os.path.isfile(fp):
            with open(fp, 'r') as f:
                txt = f.read()
            newfp = '{0}_upper{1}'.format(*os.path.splitext(fp))
            with open(newfp, 'w') as f:
                f.write(txt.upper())
    
    
    if __name__ == '__main__':
        main()
    

