Answer the question
In order to leave comments, you need to log in
Python What is the best way to check if there is a common element?
There is a string a and a tuple signs how can the code be shortened as much as possible so that the function checks if there is at least one of the signs in this string?
signs=('.','!','?')
def sign(a):
t=False
for i in a:
if i in signs:
t=True
break
return t
...
if sign(text[i].cont) and (i!=len(text)-1):
...
Answer the question
In order to leave comments, you need to log in
Why lambda when there is a standard library:
s = "здесь есть знаки препинания?"
print(any(c in ".!?" for c in s))
If you absolutely need through map, and it doesn’t matter that a little more action will be performed.any(map(lambda x: x in signs, a))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question