Re: uplownumpnct.py
Mats Wichmann <[email protected]> Mon, 1 Jan 2024 12:42:14 -0700
| Newsgroups | gmane.comp.python.tutor |
|---|---|
| Message-ID | <[email protected]> |
On 1/1/24 10:22, Ethan Rosenberg wrote:
> Tutor -
>
> What is my syntax error?
As people have asked you *multiple* times before, paste the full error
message. It will tell you what the syntax error is. If you don't
understand it, someone can help interpret - that's a whole lot easier
than looking at code (often malformed by the mailer).
This is an obvious one:
> pnct = [:,;.,,]
> spec = [!,@,<,#,>,},$,%,&,?,*,(,),{,/,' ']
You can't just toss in a bunch of character that have syntactic meaning
to Python. If you want a set of characters, you need to present them as
a set of characters - since you're defining these as a list, you should
enclose each punctuation/special character in quotes. If one of them is
a quote itself, use the other quote mark for it.
Also, you can get these from Python
>>> import string
>>> string.punctuation
'!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~'
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor