def disemvowel(string): return ("".join(char for char in string if char.lower() not in "aeiou"))
import timeimport randomimport stringletters = string.ascii_lettersfunc1 = lambda x: ''.join(y for y in x if y.lower() not in 'aeiou')func2 = lambda x: ''.join(y for y in x if y.lower() not in 'aeiou')for func, name in ((func1, 'filter '), (func2, 'boolean')):start = time.time()for _ in range(80000):word = ''.join(random.choice(letters) for _ in range(70))func(word)print(f'Function with {name} took {round(time.time() - start, 5)} seconds')disemvowel = func2- def disemvowel(string):
- return ("".join(char for char in string if char.lower() not in "aeiou"))