Nov-05-2019, 11:15 PM
i have a container of strings. it can be made available in whatever type is most convenient for the best solution, such as a list, or set. what i want to do is find if a given string is a "begins with" substring of exactly one string element of the container. an alternative is to find out the number of such matches or get a list of such matches. for example:
container = ('alignment','aliases') ops = ('foo','ali','alia','bar') for op in ops: result = find_matches(container,op) if len(result)==1: print(f'we have a match for "{op}" at "{result[0]}"') breakthe output should be:
Output:we have a match for "alia" at "aliases"
Tradition is peer pressure from dead people
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.