In this lab, you will be tasked with writing several functions that require you to use lists and some string methods.
You should create one file named lab6.py
and put all of the functions you complete, along with the test-cases, in the same file.
Submit just this file to D2L when you are finished.
Write a function named separate_into_lines .
This function will take two parameters.
The first you can assume is a string, and the second is a string that will have a single character in it.
The function will split the string based on that single character.
It will print each of the resulting list elements on their own line.
You'll want to use the split() function to do this.
|
Write a function named get_longest_word .
This functtion will take on parameter: A sentence of text (a string).
This function will find the longest word in the string and return it.
You can assume that the input parameter will have at least one word in it.
For example, these tests:
|
Create a function named get_word_lengths .
This function will accept a single parameter, a sentence of words.
This function will return a new list, which will have the same length as the number of words in the parameter string
The returned list should have a number that corresponds to the length of the words at that position in the parameter.
For example, these tests:
|
Create a function named print_triples .
This function will take a single string in as a parameter.
The string will be a sequence of words, separated by the comma character (,), and the number of words will be a multiple of three.
The function will print out chunks of three words at-a-time, separated by a space instead of a comma.
This test case:
|
You must turn in at least 2 of the problems on D2L to get credit for this.