Hi Abhinaya,
Creating text files (.txt and .csv) and creating word documents (.doc or docx) are two entirely different problems.
Text files are pretty simple and can be handled with base python, no extra modules required, csv files are text files so the same applies to them
Word documents imply all sorts of complications such as formatting (fonts, colours, bold, italics, etc), tables, headings, dynamic data (table of contents), headers and footers, embedded objects (images, other documents) and so on and so on.
Also a .doc file is a proprietary format, so while i've seen modules that can deal with .doc files there are limits to how well they support these files as it's a case of how well the module maintainer managed to reverse engineer the .doc files and which versions that module works with.
A better way of dealing with word documents is to use the .docx files which have much better support, probably want to look at this module:
Finally, you can just pass your function the full file name rather than passing the extension separately, the os.path.splitext() function will seperate the extension from the file name and path for you so that way your generic function can be easier to use.
Hope that helps you get started,
Dave.