Question: 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.')

I'll rate it up once you explain the logic. Here is my

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 "" and "" are strings. The product of their lengths is ) and return a function's output with return. 295818.1713114 LAB ACTIVITY 5.17.1: Breakout Rooms: String Character Multiplier 4/5 Load default template... main.py 9# 10 # If they are not both strings, print the following: 11 # "Incorrect argument type found. Expected strings." 12 # Then return false 13 14 def word_mult(word, word2): 15 if (type (wordl) == str) and (type (word2) == str): 16 return len(word) * len(word) 17 else: 18 return false 19 if _name__ == '__main__': 29 wordi input() 21 word2 = input() 22 if (type (wordl) == str) and (type (word) == str): 23 print('Both "{}" and "{}" are strings.'.format(word, word)) 24 print('The product of their lengths is .'.format(word_mult(word, word2))) 25 else: 26 print('Incorrect argument type found. Expected strings.')

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!