Python Forum

Full Version: Problem with slicing string
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Can you help me figure out what is the issue in the below code.

My Code:

email = input("What is your email add: ")
#UN = email[:email.index("@")]
print(email)
Error:
>>> ================================ RESTART ================================
>>> 
What is your email add: asdasdasdasdasdasd


Error:
Traceback (most recent call last):   File "C:/Users/ykarkera/Desktop/Python Bible/Strings.py", line 1, in <module>     email = input("What is your email add: ")   File "<string>", line 1, in <module> NameError: name 'asdasdasdasdasdasd' is not defined
>>>
Use raw_input() instead of input()
Python 2 ?

Python 2 see the input() returns as a valid Python statement/code. So there is no variable called 'asdasdasdasdasdasd' and you get an error.
Yes 2.7 version.

raw_input worked. Thanks!