Hello guys,
I have a program created that opens a program and execute it as well.

For example:

filename = raw_input('Input a valid NAPS filename -> ')
execfile(filename)

I put my file helloworld.naps (my file extension)
And it execute smoothly.

Now my question is, how to verify the user input if there is a .naps file extension in their file.
If they have not, then there will be an error that displays 'You have entered an invalid filename'. I got the logic but I dunno how to code it.

Well, you have

>>> import os
>>> filename = "foo/bar/baz/qux.naps"
>>> name = os.path.basename(filename)
>>> name
'qux.naps'
>>> base, extension = os.path.splitext(name)
>>> base
'qux'
>>> extension
'.naps'

and also

>>> os.path.exists(filename) # check if file exists
False
# or
>>> os.path.isfile(filename) # check if a regular file with that name exists
False

I tried this code of yours and put some if-elif statements and its now fully working.
I'm really thankful for the quick response sir. Soon if I quite learn more about python, I'll contribute to this community. ^__^

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.