Question
def remove_punctuation(text: str) -> str: Simple function to remove punctuation from text :param text: text to remove punctuation from :return: text with punctuation removed
def remove_punctuation(text: str) -> str:
""" Simple function to remove punctuation from text
:param text: text to remove punctuation from
:return: text with punctuation removed """
return ''.join([ character for character in text if character not in string.punctuation ])
def word_count_map_function(text: str) -> list[tuple[str, int]]:
""" Simple map function that takes text and outputs tuples of words and counts :param text: text to convert into word/count tuples
:return: A list of tuples with word and count """
# TODO: Implement the word count map function # Step 1: Remove punctuation from text # Step 2: Convert text to lower case # Step 3: Split the text by spaces to convert into words # Step 4: Return a list containing a dictionary of words and counts # This line is here as a placeholder. Replace with your own code
words = [] # This line is here as a placeholder. Replace with your own code word_count_pairs = [('word1', 1), ('word2', 1)]
return word_count_pairs
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started