(Jan-18-2020, 09:08 PM)bertilow Wrote: I want to be able to check if a string contains any of the following "funny" characters
There is built-in any() which could be used for checking:
>>> checklist = "ā㥹ĆćČčĎďĐđēĕĖėęěĞğġīįİıĽľŁłŃńņňŋŌōőŒœŕřŚśŞşŠšŢţťŧũūŮűųŹźŻżŽžſ" >>> s = "abcdefghijklmnopqrstuvwxyz" >>> any(char in checklist for char in s) False >>> s = 'abcā' >>> any(char in checklist for char in s) TrueExplained:
for char in s
for every character in string to be checkedchar in checklist
return boolean value whether character is in checklistany()
has short-circuit behaviour i.e. if first character which is in checklist (boolean value True) is found it stops and returns True
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.