Clearly not a problem with an assignment:
pax@pax-desktop:~$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> end= " "
>>> len(end)
1
>>>
Therefore there must be another issue. Short of seeing the error message and actual code, the only suggestions I can make are:
- Check indentation. Python is notoriously picky about this since it's how it decides what blocks of code are.
- Check that the quote marks are the regular ones, not something like
“ ”
cut'n'pasted from a Word document or web page.
That last one is particularly annoying when web page creators can't be bothered posting proper code (or their presentation engines munge it) and, on my system, results in:
pax@pax-desktop:~$ python
Python 2.7.1+ (r271:86832, Apr 11 2011, 18:05:24)
[GCC 4.5.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> end= “ ”
File "<stdin>", line 1
end= “ ”
^
SyntaxError: invalid syntax