Def longest_word(word1, word2, word3):
if len(word1) >= len(word2) and len(word1) >= len(word3):
word = word1
elif len(word2) >= len(word1) and len(word2) >= len(word3):
word = word2
else:
word = word3
return(word)
print(longest_word("chair", "couch", "table"))
print(longest_word("bed", "bath", "beyond"))
print(longest_word("laptop", "notebook", "desktop"))
for the above question when i run the program the ans was
chair
beyond
notebook
can anybody explain me how notebook was printed and executed
Answers
Answered by
0
The longest_word function is used to compare 3 words. \n " , " It should return the word with the most number of characters (and the first in the list when they have the same length).
Answered by
6
Answer:
def longest_word(word1, word2, word3):
if len(word1) >= len(word2) and len(word1) >= len(word3):
word = word1
elif len(word2) >= len(word1) and len(word2) >= len(word3):
word = word2
else:
word = word3
return(word)
print(longest_word("chair", "couch", "table"))
print(longest_word("bed", "bath", "beyond"))
print(longest_word("laptop", "notebook", "desktop"))
Explanation:
Similar questions
English,
5 months ago
English,
5 months ago
Math,
5 months ago
English,
10 months ago
Political Science,
1 year ago
Computer Science,
1 year ago
Math,
1 year ago