Close
Close

plz help me understand the working of last question of dictionary?

   Prathamesh Saraf , D.K.T.E. Ichalajaranji


Answers

  •   

    The question is:

    Take a list containg only strings. Now, take a string input from user and rearrange the elements of the list according to the number of occurence of the string taken from user in the elements of the list.
    E.g.-LIST : ["no bun","bug bun bug bun bug bug","bunny bug","buggy bug bug buggy"]
    STRING TAKEN : "bug"
    OUTPUT LIST:["bug bun bug bun bug bug","buggy bug bug buggy","bunny bug","no bun"]

    In this example, the string taken as input is “bug”. So, we have to rearrange the every element of the list according to the number of occurrence of the string “bug” in them.

    "bug bun bug bun bug bug" → Number of times “bug” appears is 4 (maximum times). So, it will be the first element in the arranged list.

    "buggy bug bug buggy" → Number of times “bug” appears is 2. So, it will be the second element in the arranged list.

    Similarly proceed further.



Ask Yours
Post Yours
Write your answer