Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I'll rate it up once you explain the logic. Here is my code. def word_mult(word1, word2): if (type(word1) == str) and (type(word2) == str): return
I'll rate it up once you explain the logic. Here is my code.
def word_mult(word1, word2): if (type(word1) == str) and (type(word2) == str): return len(word1) * len(word2) else: return False if __name__ == '__main__': word1 = input() word2 = input() if (type(word1) == str) and (type(word2) == str): print('Both "{}" and "{}" are strings.'.format(word1, word2)) print('The product of their lengths is .'.format(word_mult(word1, word2))) else: print('Incorrect argument type found. Expected strings.')
In this lab, we will practice writing functions that both display (ie: print) and return values. This will all be done in the word_mult() function below. Given two inputs, write a function word_mult(word, word2) that will: Confirm both word1 and word2 are of type str o If they are both strings, compute the product of the two string lengths. Then print the following: Both "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