Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
From '"' to '''' solution in Clear category for Find Quotes by mikaeldovbnia
def find_quotes(a):
s = []
for o, i in enumerate(a):
if i == '"':
s.append(o)
f1 = s[::2]
f2 = s[1::2]
g = list(zip(f1, f2))
k = []
for u in g:
k.append(a[u[0] + 1:u[-1]])
return k
if __name__ == '__main__':
print("Example:")
print(find_quotes('"Greetings"'))
# These "asserts" are used for self-checking and not for an auto-testing
assert find_quotes('"Greetings"') == ['Greetings']
assert find_quotes('Hi') == []
assert find_quotes('good morning mister "superman"') == ['superman']
assert find_quotes('"this" doesn\'t make any "sense"') == ['this', 'sense']
assert find_quotes('"Lorem Ipsum" is simply dummy text '
'of the printing and typesetting '
'industry. Lorem Ipsum has been the '
'"industry\'s standard dummy text '
'ever since the 1500s", when an '
'unknown printer took a galley of '
'type and scrambled it to make a type '
'specimen book. It has survived not '
'only five centuries, but also the '
'leap into electronic typesetting, '
'remaining essentially unchanged. "It '
'was popularised in the 1960s" with '
'the release of Letraset sheets '
'containing Lorem Ipsum passages, and '
'more recently with desktop '
'publishing software like Aldus '
'PageMaker including versions of '
'Lorem Ipsum.') == ['Lorem Ipsum',
"industry's standard dummy text ever "
'since the 1500s',
'It was popularised in the 1960s']
assert find_quotes('count empty quotes ""') == ['']
print("Coding complete? Click 'Check' to earn cool rewards!")
April 24, 2022