a = input("enter the string")
print "%s dinesh" %l
m=re.match(r'(.*)(\.*)',l,re.I)
print m.group()
print m.group(2)

i m getting the following error ,when i give input

Traceback (most recent call last):
  File "regularexp.py", line 1, in <module>
    a = input("enter the string")
  File "<string>", line 1, in <module>
NameError: name 'dinesh' is not defined

If you are using Python3.X input is fine. If you are using Python2.x then input captures numbers, and raw_input captures strings.

If you're on 3.x version of Python, then you'd have to have the print function as a function, meaning print (" "), but clearly that's not the case having the NameError error:

NameError: name 'dinesh' is not defined

and the simple print statement:

print "%s dinesh" %l

Well all of this means that you're on python lower to 3.x, well, 2.x.
In this versions of Python 2.x, input is used only to gather number, integers, as integers, and obvious not for strings.
If you'd like to add strings, you'd need to use the raw_input(" ") statement, which will return the input as a string.
For more information visit http://docs.python.org/library/functions.html#input
So, your code should look like this:

a = raw_input("Enter the string: ")
print "%s dinesh" %l
m=re.match(r'(.*)(\.*)',l,re.I)
print m.group()
print m.group(2)

Edited 4 Years Ago by Lucaci Andrew: n/a

Also another thing to note is that with python 2.x you should not use input at all as it actually calls the eval() function which can give your problems with certain numbers so use

int(raw_input())
This question has already been answered. Start a new discussion instead.