Question: Python: Using the sentence all kids like ice cream, define (def) a function lenumerate() in simple code that uses that string and returns a list

Python: Using the sentence all kids like ice cream, define (def) a function lenumerate() in simple code that uses that string and returns a list of lists, each containing the word and it's length. Also, call the function and print its return. Words are defined separated by white-space within the string. It will look like this: [["all", 3], ["kids", 4], ... , ["cream", 5]]

Then, come up with a second version of the lenumerate() function (name it lenumerate2() ) that uses as second argument a boolean (i.e. True or False) called other. The default value for other shall be False. If other is False the same list as in lenumerate() will be returned, and If other is True, the order of the 2 items are reversed: other=True => [[3, all], [4, kids]

Call lenumerate2() two times: 1. Same as your call of lenumerate() before.. As other is set to False be default, the output should also be the same as previously (not reversed 2. set other to True, but this time as keyword argument(!), so the output should be reversed.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!