Skip to main content
edited title
Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

Checking whether anya string ends with one of a list of suffixes

edited tags; edited title
Link
200_success
  • 144.2k
  • 22
  • 188
  • 473

Perform Checking whether any string ends with one of a boolean function to list and get 'OR' in pythonof suffixes

Post Reopened by 200_success
edited body
Source Link
Loom
  • 555
  • 4
  • 19

I want to check if some line ends with any substring defined in some list. Is there a better way than following one?

endsA = ['foo', 'bar', 'fur', 'beer']
endsB = ['door', ... ]

def checkEnds(line, ends):
    for end in ends:
        if line.endsWihtendswith(end):
            return True

....

if checkEnds(line, endsA):
    do_something()

I want to check if some line ends with any substring defined in some list. Is there a better way than following one?

endsA = ['foo', 'bar', 'fur', 'beer']
endsB = ['door', ... ]

def checkEnds(line, ends):
    for end in ends:
        if line.endsWiht(end):
            return True

....

if checkEnds(line, endsA):
    do_something()

I want to check if some line ends with any substring defined in some list. Is there a better way than following one?

endsA = ['foo', 'bar', 'fur', 'beer']
endsB = ['door', ... ]

def checkEnds(line, ends):
    for end in ends:
        if line.endswith(end):
            return True

....

if checkEnds(line, endsA):
    do_something()
Post Closed as "Not suitable for this site" by 200_success
Post Reopened by 200_success
Post Closed as "Not suitable for this site" by 200_success
Source Link
Loom
  • 555
  • 4
  • 19
Loading