Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

# You can assume that the function argument, gibberish, # is a string consisting of nothing but distinct letters # (a letter can occur twice,

# You can assume that the function argument, gibberish,

# is a string consisting of nothing but distinct letters

# (a letter can occur twice, once in uppercase, once in

# lowercase).

#

# Returns the set of all strings consisting of letters in

# gibberish, MAINTAINING THE ORDER THEY HAVE in gibberish,

# a vowel in the string either ending the string or being

# followed by a consonant, a consonant in the string either

# ending the string or being followed by a vowel.

#

# Vowels are A, E, I, O, U and their lowercase counterparts.

def f(gibberish):

'''

>>> f('')

{''}

>>> f('A') == {'', 'A'}

True

>>> f('aeio') == {'', 'e', 'a', 'o', 'i'}

True

>>> f('AB') == {'', 'A', 'B', 'AB'}

True

>>> f('ABE') == {'', 'E', 'A', 'B', 'ABE', 'BE', 'AB'}

True

>>> f('AEB') == {'', 'A', 'AB', 'B', 'E', 'EB'}

True

>>> f('bBaA') == {'', 'a', 'ba', 'B', 'A', 'b', 'bA', 'BA', 'Ba'}

True

>>> f('BCADae') == {'', 'CAD', 'BADe', 'e', 'Ca', 'CADe', \

'ADa', 'Ba', 'BADa', 'Ce', 'ADe', 'a', 'Da', 'CA', 'Be', \

'BA', 'C', 'D', 'A', 'CADa', 'AD', 'B', 'BAD', 'De'}

True

'''

# INSERT YOUR CODE HERE

if __name__ == '__main__':

import doctest

doctest.testmod()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Transport Operations

Authors: Allen Stuart

2nd Edition

978-0470115398, 0470115394

Students also viewed these Programming questions