Q. Write a short Python code segment that adds up the lengths of all the words in a list and then prints the average (mean) length.
Answer :-
count= 0 lst = eval(input("Enter a list :-")) for i in lst: count += len(i) print("Mean:" ,count/len(lst))
Output :-
Enter a list :-[ "Path", 'Walla', "Python" ]
Mean: 5.0
>>>
Mean: 5.0
>>>
Enter a list :- [ "HTML", "CSS", "C++", "C#", "JAVA"]
Mean: 3.2
>>>
output of this program??
ReplyDeleteOk, I have updated it.
DeleteThis program is showing error in my pc 😥ðŸ˜ðŸ˜ðŸ˜
ReplyDeletewhat if the list is nested?
ReplyDeleteWe have to use nested loop.
Deletecan we use statistics module?
ReplyDeletePost a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )