how to display the number of vowels in a list?How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How to make a flat list out of list of listsHow do I get the number of elements in a list?How to clone or copy a list?How do I list all files of a directory?How to read a file line-by-line into a list?

How do I safety check that there is no light in Darkroom / Darkbag?

Why wasn't interlaced CRT scanning done back and forth?

Approximating an expression for a potential

Why are sugars in whole fruits not digested the same way sugars in juice are?

Proof of First Difference Property for Fourier Series

A verb for when some rights are not violated?

What is Albrecht Dürer's Perspective Machine drawing style?

Any information about the photo with Army Uniforms

Why does the friction act on the inward direction when a car makes a turn on a level road?

Is it moral to remove/hide certain parts of a photo, as a photographer?

Is an "are" omitted in this sentence

In MTG, was there ever a five-color deck that worked well?

How to design an effective polearm-bow hybrid?

Lower bound for the number of lattice points on high dimensional spheres

What does Argus Filch specifically do?

Who's behind community AMIs on Amazon EC2?

Reasons for using monsters as bioweapons

Why is the Vasa Museum in Stockholm so Popular?

How can I perform a deterministic physics simulation?

Meaning of ギャップ in the following sentence

Astable 555 circuit not oscillating

Is this popular optical illusion made of a grey-scale image with coloured lines?

A wiild aanimal, a cardinal direction, or a place by the water

Does a bard know when a character uses their Bardic Inspiration?



how to display the number of vowels in a list?


How to merge two dictionaries in a single expression?How do I check if a list is empty?How do I check whether a file exists without exceptions?Finding the index of an item given a list containing it in PythonWhat is the difference between Python's list methods append and extend?How to make a flat list out of list of listsHow do I get the number of elements in a list?How to clone or copy a list?How do I list all files of a directory?How to read a file line-by-line into a list?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








-1















first, I need to write a program that displays the names of the planets in the list Planets in descending order by their position from the Sun.
then, I should rite a program that displays the names of the planets in the list Planets in ascending order by the number of vowels in planet name.



I have been able to do the first part. however, I couldn't the second part.



Planets = [("Mercury", 75, 1), ("Venus", 460, 2), ("Mars", 140, 4),
("Earth", 510, 3), ("Jupiter", 62000, 5), ("Neptune", 7640, 8),
("Saturn", 42700, 6), ("Uranus", 8100, 7)]


def main():
Planets.sort(key=Sort_By_Position,reverse=True)
print("The names of the planets in descending order by their position from the Sun: ")
for i in Planets:
print (i[0])

print(" ")

print("Planets in ascending order by the number of vowels in planet name: ")
Planets.sort(key=vowel_count)
for i in Planets:
print(i[0])

def Sort_By_Position(Planets):
return Planets[-1]

def vowel_count():


main()


I expect the program to show me the ascending order of planets by the number of vowels in planet name.










share|improve this question





















  • 2





    you didn’t implement a function to count vowels so why would you expect it to sort by vowels

    – aws_apprentice
    Mar 27 at 0:56











  • Hi, StackOverflow doesn't exist to do your homework for you. That doesn't mean you can't ask questions about your homework, though. You are much more likely to get a useful answer if you at least tried to implement vowel counting in some way. e.g. try googling for functions to do it for at least one string, and then give a go at iterating it over your list. If that doesn't work, ask specific questions about the problems that you encountered, rather than ask someone to provide the complete solution for you.

    – Michael MacAskill
    Mar 27 at 1:32

















-1















first, I need to write a program that displays the names of the planets in the list Planets in descending order by their position from the Sun.
then, I should rite a program that displays the names of the planets in the list Planets in ascending order by the number of vowels in planet name.



I have been able to do the first part. however, I couldn't the second part.



Planets = [("Mercury", 75, 1), ("Venus", 460, 2), ("Mars", 140, 4),
("Earth", 510, 3), ("Jupiter", 62000, 5), ("Neptune", 7640, 8),
("Saturn", 42700, 6), ("Uranus", 8100, 7)]


def main():
Planets.sort(key=Sort_By_Position,reverse=True)
print("The names of the planets in descending order by their position from the Sun: ")
for i in Planets:
print (i[0])

print(" ")

print("Planets in ascending order by the number of vowels in planet name: ")
Planets.sort(key=vowel_count)
for i in Planets:
print(i[0])

def Sort_By_Position(Planets):
return Planets[-1]

def vowel_count():


main()


I expect the program to show me the ascending order of planets by the number of vowels in planet name.










share|improve this question





















  • 2





    you didn’t implement a function to count vowels so why would you expect it to sort by vowels

    – aws_apprentice
    Mar 27 at 0:56











  • Hi, StackOverflow doesn't exist to do your homework for you. That doesn't mean you can't ask questions about your homework, though. You are much more likely to get a useful answer if you at least tried to implement vowel counting in some way. e.g. try googling for functions to do it for at least one string, and then give a go at iterating it over your list. If that doesn't work, ask specific questions about the problems that you encountered, rather than ask someone to provide the complete solution for you.

    – Michael MacAskill
    Mar 27 at 1:32













-1












-1








-1








first, I need to write a program that displays the names of the planets in the list Planets in descending order by their position from the Sun.
then, I should rite a program that displays the names of the planets in the list Planets in ascending order by the number of vowels in planet name.



I have been able to do the first part. however, I couldn't the second part.



Planets = [("Mercury", 75, 1), ("Venus", 460, 2), ("Mars", 140, 4),
("Earth", 510, 3), ("Jupiter", 62000, 5), ("Neptune", 7640, 8),
("Saturn", 42700, 6), ("Uranus", 8100, 7)]


def main():
Planets.sort(key=Sort_By_Position,reverse=True)
print("The names of the planets in descending order by their position from the Sun: ")
for i in Planets:
print (i[0])

print(" ")

print("Planets in ascending order by the number of vowels in planet name: ")
Planets.sort(key=vowel_count)
for i in Planets:
print(i[0])

def Sort_By_Position(Planets):
return Planets[-1]

def vowel_count():


main()


I expect the program to show me the ascending order of planets by the number of vowels in planet name.










share|improve this question
















first, I need to write a program that displays the names of the planets in the list Planets in descending order by their position from the Sun.
then, I should rite a program that displays the names of the planets in the list Planets in ascending order by the number of vowels in planet name.



I have been able to do the first part. however, I couldn't the second part.



Planets = [("Mercury", 75, 1), ("Venus", 460, 2), ("Mars", 140, 4),
("Earth", 510, 3), ("Jupiter", 62000, 5), ("Neptune", 7640, 8),
("Saturn", 42700, 6), ("Uranus", 8100, 7)]


def main():
Planets.sort(key=Sort_By_Position,reverse=True)
print("The names of the planets in descending order by their position from the Sun: ")
for i in Planets:
print (i[0])

print(" ")

print("Planets in ascending order by the number of vowels in planet name: ")
Planets.sort(key=vowel_count)
for i in Planets:
print(i[0])

def Sort_By_Position(Planets):
return Planets[-1]

def vowel_count():


main()


I expect the program to show me the ascending order of planets by the number of vowels in planet name.







python






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 27 at 1:09









Hoppeduppeanut

5842 gold badges11 silver badges18 bronze badges




5842 gold badges11 silver badges18 bronze badges










asked Mar 27 at 0:50









Abdulrahman BaothmanAbdulrahman Baothman

1




1










  • 2





    you didn’t implement a function to count vowels so why would you expect it to sort by vowels

    – aws_apprentice
    Mar 27 at 0:56











  • Hi, StackOverflow doesn't exist to do your homework for you. That doesn't mean you can't ask questions about your homework, though. You are much more likely to get a useful answer if you at least tried to implement vowel counting in some way. e.g. try googling for functions to do it for at least one string, and then give a go at iterating it over your list. If that doesn't work, ask specific questions about the problems that you encountered, rather than ask someone to provide the complete solution for you.

    – Michael MacAskill
    Mar 27 at 1:32












  • 2





    you didn’t implement a function to count vowels so why would you expect it to sort by vowels

    – aws_apprentice
    Mar 27 at 0:56











  • Hi, StackOverflow doesn't exist to do your homework for you. That doesn't mean you can't ask questions about your homework, though. You are much more likely to get a useful answer if you at least tried to implement vowel counting in some way. e.g. try googling for functions to do it for at least one string, and then give a go at iterating it over your list. If that doesn't work, ask specific questions about the problems that you encountered, rather than ask someone to provide the complete solution for you.

    – Michael MacAskill
    Mar 27 at 1:32







2




2





you didn’t implement a function to count vowels so why would you expect it to sort by vowels

– aws_apprentice
Mar 27 at 0:56





you didn’t implement a function to count vowels so why would you expect it to sort by vowels

– aws_apprentice
Mar 27 at 0:56













Hi, StackOverflow doesn't exist to do your homework for you. That doesn't mean you can't ask questions about your homework, though. You are much more likely to get a useful answer if you at least tried to implement vowel counting in some way. e.g. try googling for functions to do it for at least one string, and then give a go at iterating it over your list. If that doesn't work, ask specific questions about the problems that you encountered, rather than ask someone to provide the complete solution for you.

– Michael MacAskill
Mar 27 at 1:32





Hi, StackOverflow doesn't exist to do your homework for you. That doesn't mean you can't ask questions about your homework, though. You are much more likely to get a useful answer if you at least tried to implement vowel counting in some way. e.g. try googling for functions to do it for at least one string, and then give a go at iterating it over your list. If that doesn't work, ask specific questions about the problems that you encountered, rather than ask someone to provide the complete solution for you.

– Michael MacAskill
Mar 27 at 1:32












3 Answers
3






active

oldest

votes


















0














here is solution



Planets = [("Mercury", 75, 1), ("Venus", 460, 2), ("Mars", 140, 4), ("Earth", 510, 3), ("Jupiter", 62000, 5), ("Neptune", 7640, 8), ("Saturn", 42700, 6), ("Uranus", 8100, 7)]

# decending order in order
new_pl=Planets.copy()
new_pl.sort(key=lambda x:x[2], reverse=True) # sorting on position value

print(new_pl)

"""
output
[('Neptune', 7640, 8), ('Uranus', 8100, 7), ('Saturn', 42700, 6), ('Jupiter', 62000, 5), ('Mars', 140, 4), ('Earth', 510, 3), ('Venus', 460, 2), ('Mercury', 75, 1)]
"""


# in no of vowels present
vowel = ['a','e','i','o','u']

# in vowels
def count(name):
vowel = ['a','e','i','o','u']
val=0
for i in name.lower():
if i in vowel:
val+=1
return val

new_pl_2=Planets.copy()

new_pl_2.sort(key=lambda x:count(x[0])) #sorting on count of vowels
print(new_pl_2)

"""
output

[('Mars', 140, 4), ('Mercury', 75, 1), ('Venus', 460, 2), ('Earth', 510, 3), ('Saturn', 42700, 6), ('Jupiter', 62000, 5), ('Neptune', 7640, 8), ('Uranus', 8100, 7)]
"""





share|improve this answer
































    0














    You can do this in one line using a list comprehension.



    def vowel_count(elem):
    return len([x for x in elem[0] if x in ('a', 'e', 'i', 'o', 'u')])


    elem[0] contains the name of the planet you are iterating over. When you iterate over a string (x in elem[0]), it will iterate each individual character in that string. For example, 'Earth' becomes ['E', 'a', 'r', 't', 'h'].



    From there, we can simply filter the list comprehension to only contain vowels (if x.lower() in ('a', 'e', 'i', 'o', 'u')) and return the length of the comprehension, which is fed back to the sort method.






    share|improve this answer
































      0














      You mentioned that you were able to do the first part so you are essentially only asking about the second part. The following example should help get you pointed in the right direction:



      >>> planets = ['Mercury','Venus','Earth','Mars','Neptune','Jupiter','Saturn','Uranus']
      >>> vowels = ('a','e','i','o','u')
      >>> name_counts = []
      >>> for name in planets:
      ... count = sum([1 for letter in name if letter.lower() in vowels])
      ... name_counts.append((name,count))
      ...
      >>> print(sorted(name_counts, key=lambda x: x[1]))
      [('Mars', 1), ('Mercury', 2), ('Venus', 2), ('Earth', 2), ('Saturn', 2), ('Neptune', 3), ('Jupiter', 3), ('Uranus', 3)]





      share|improve this answer





























        Your Answer






        StackExchange.ifUsing("editor", function ()
        StackExchange.using("externalEditor", function ()
        StackExchange.using("snippets", function ()
        StackExchange.snippets.init();
        );
        );
        , "code-snippets");

        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "1"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: true,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: 10,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368220%2fhow-to-display-the-number-of-vowels-in-a-list%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        0














        here is solution



        Planets = [("Mercury", 75, 1), ("Venus", 460, 2), ("Mars", 140, 4), ("Earth", 510, 3), ("Jupiter", 62000, 5), ("Neptune", 7640, 8), ("Saturn", 42700, 6), ("Uranus", 8100, 7)]

        # decending order in order
        new_pl=Planets.copy()
        new_pl.sort(key=lambda x:x[2], reverse=True) # sorting on position value

        print(new_pl)

        """
        output
        [('Neptune', 7640, 8), ('Uranus', 8100, 7), ('Saturn', 42700, 6), ('Jupiter', 62000, 5), ('Mars', 140, 4), ('Earth', 510, 3), ('Venus', 460, 2), ('Mercury', 75, 1)]
        """


        # in no of vowels present
        vowel = ['a','e','i','o','u']

        # in vowels
        def count(name):
        vowel = ['a','e','i','o','u']
        val=0
        for i in name.lower():
        if i in vowel:
        val+=1
        return val

        new_pl_2=Planets.copy()

        new_pl_2.sort(key=lambda x:count(x[0])) #sorting on count of vowels
        print(new_pl_2)

        """
        output

        [('Mars', 140, 4), ('Mercury', 75, 1), ('Venus', 460, 2), ('Earth', 510, 3), ('Saturn', 42700, 6), ('Jupiter', 62000, 5), ('Neptune', 7640, 8), ('Uranus', 8100, 7)]
        """





        share|improve this answer





























          0














          here is solution



          Planets = [("Mercury", 75, 1), ("Venus", 460, 2), ("Mars", 140, 4), ("Earth", 510, 3), ("Jupiter", 62000, 5), ("Neptune", 7640, 8), ("Saturn", 42700, 6), ("Uranus", 8100, 7)]

          # decending order in order
          new_pl=Planets.copy()
          new_pl.sort(key=lambda x:x[2], reverse=True) # sorting on position value

          print(new_pl)

          """
          output
          [('Neptune', 7640, 8), ('Uranus', 8100, 7), ('Saturn', 42700, 6), ('Jupiter', 62000, 5), ('Mars', 140, 4), ('Earth', 510, 3), ('Venus', 460, 2), ('Mercury', 75, 1)]
          """


          # in no of vowels present
          vowel = ['a','e','i','o','u']

          # in vowels
          def count(name):
          vowel = ['a','e','i','o','u']
          val=0
          for i in name.lower():
          if i in vowel:
          val+=1
          return val

          new_pl_2=Planets.copy()

          new_pl_2.sort(key=lambda x:count(x[0])) #sorting on count of vowels
          print(new_pl_2)

          """
          output

          [('Mars', 140, 4), ('Mercury', 75, 1), ('Venus', 460, 2), ('Earth', 510, 3), ('Saturn', 42700, 6), ('Jupiter', 62000, 5), ('Neptune', 7640, 8), ('Uranus', 8100, 7)]
          """





          share|improve this answer



























            0












            0








            0







            here is solution



            Planets = [("Mercury", 75, 1), ("Venus", 460, 2), ("Mars", 140, 4), ("Earth", 510, 3), ("Jupiter", 62000, 5), ("Neptune", 7640, 8), ("Saturn", 42700, 6), ("Uranus", 8100, 7)]

            # decending order in order
            new_pl=Planets.copy()
            new_pl.sort(key=lambda x:x[2], reverse=True) # sorting on position value

            print(new_pl)

            """
            output
            [('Neptune', 7640, 8), ('Uranus', 8100, 7), ('Saturn', 42700, 6), ('Jupiter', 62000, 5), ('Mars', 140, 4), ('Earth', 510, 3), ('Venus', 460, 2), ('Mercury', 75, 1)]
            """


            # in no of vowels present
            vowel = ['a','e','i','o','u']

            # in vowels
            def count(name):
            vowel = ['a','e','i','o','u']
            val=0
            for i in name.lower():
            if i in vowel:
            val+=1
            return val

            new_pl_2=Planets.copy()

            new_pl_2.sort(key=lambda x:count(x[0])) #sorting on count of vowels
            print(new_pl_2)

            """
            output

            [('Mars', 140, 4), ('Mercury', 75, 1), ('Venus', 460, 2), ('Earth', 510, 3), ('Saturn', 42700, 6), ('Jupiter', 62000, 5), ('Neptune', 7640, 8), ('Uranus', 8100, 7)]
            """





            share|improve this answer













            here is solution



            Planets = [("Mercury", 75, 1), ("Venus", 460, 2), ("Mars", 140, 4), ("Earth", 510, 3), ("Jupiter", 62000, 5), ("Neptune", 7640, 8), ("Saturn", 42700, 6), ("Uranus", 8100, 7)]

            # decending order in order
            new_pl=Planets.copy()
            new_pl.sort(key=lambda x:x[2], reverse=True) # sorting on position value

            print(new_pl)

            """
            output
            [('Neptune', 7640, 8), ('Uranus', 8100, 7), ('Saturn', 42700, 6), ('Jupiter', 62000, 5), ('Mars', 140, 4), ('Earth', 510, 3), ('Venus', 460, 2), ('Mercury', 75, 1)]
            """


            # in no of vowels present
            vowel = ['a','e','i','o','u']

            # in vowels
            def count(name):
            vowel = ['a','e','i','o','u']
            val=0
            for i in name.lower():
            if i in vowel:
            val+=1
            return val

            new_pl_2=Planets.copy()

            new_pl_2.sort(key=lambda x:count(x[0])) #sorting on count of vowels
            print(new_pl_2)

            """
            output

            [('Mars', 140, 4), ('Mercury', 75, 1), ('Venus', 460, 2), ('Earth', 510, 3), ('Saturn', 42700, 6), ('Jupiter', 62000, 5), ('Neptune', 7640, 8), ('Uranus', 8100, 7)]
            """






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Mar 27 at 1:01









            prashant ranaprashant rana

            2,8491 gold badge12 silver badges24 bronze badges




            2,8491 gold badge12 silver badges24 bronze badges


























                0














                You can do this in one line using a list comprehension.



                def vowel_count(elem):
                return len([x for x in elem[0] if x in ('a', 'e', 'i', 'o', 'u')])


                elem[0] contains the name of the planet you are iterating over. When you iterate over a string (x in elem[0]), it will iterate each individual character in that string. For example, 'Earth' becomes ['E', 'a', 'r', 't', 'h'].



                From there, we can simply filter the list comprehension to only contain vowels (if x.lower() in ('a', 'e', 'i', 'o', 'u')) and return the length of the comprehension, which is fed back to the sort method.






                share|improve this answer





























                  0














                  You can do this in one line using a list comprehension.



                  def vowel_count(elem):
                  return len([x for x in elem[0] if x in ('a', 'e', 'i', 'o', 'u')])


                  elem[0] contains the name of the planet you are iterating over. When you iterate over a string (x in elem[0]), it will iterate each individual character in that string. For example, 'Earth' becomes ['E', 'a', 'r', 't', 'h'].



                  From there, we can simply filter the list comprehension to only contain vowels (if x.lower() in ('a', 'e', 'i', 'o', 'u')) and return the length of the comprehension, which is fed back to the sort method.






                  share|improve this answer



























                    0












                    0








                    0







                    You can do this in one line using a list comprehension.



                    def vowel_count(elem):
                    return len([x for x in elem[0] if x in ('a', 'e', 'i', 'o', 'u')])


                    elem[0] contains the name of the planet you are iterating over. When you iterate over a string (x in elem[0]), it will iterate each individual character in that string. For example, 'Earth' becomes ['E', 'a', 'r', 't', 'h'].



                    From there, we can simply filter the list comprehension to only contain vowels (if x.lower() in ('a', 'e', 'i', 'o', 'u')) and return the length of the comprehension, which is fed back to the sort method.






                    share|improve this answer













                    You can do this in one line using a list comprehension.



                    def vowel_count(elem):
                    return len([x for x in elem[0] if x in ('a', 'e', 'i', 'o', 'u')])


                    elem[0] contains the name of the planet you are iterating over. When you iterate over a string (x in elem[0]), it will iterate each individual character in that string. For example, 'Earth' becomes ['E', 'a', 'r', 't', 'h'].



                    From there, we can simply filter the list comprehension to only contain vowels (if x.lower() in ('a', 'e', 'i', 'o', 'u')) and return the length of the comprehension, which is fed back to the sort method.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Mar 27 at 1:08









                    HoppeduppeanutHoppeduppeanut

                    5842 gold badges11 silver badges18 bronze badges




                    5842 gold badges11 silver badges18 bronze badges
























                        0














                        You mentioned that you were able to do the first part so you are essentially only asking about the second part. The following example should help get you pointed in the right direction:



                        >>> planets = ['Mercury','Venus','Earth','Mars','Neptune','Jupiter','Saturn','Uranus']
                        >>> vowels = ('a','e','i','o','u')
                        >>> name_counts = []
                        >>> for name in planets:
                        ... count = sum([1 for letter in name if letter.lower() in vowels])
                        ... name_counts.append((name,count))
                        ...
                        >>> print(sorted(name_counts, key=lambda x: x[1]))
                        [('Mars', 1), ('Mercury', 2), ('Venus', 2), ('Earth', 2), ('Saturn', 2), ('Neptune', 3), ('Jupiter', 3), ('Uranus', 3)]





                        share|improve this answer































                          0














                          You mentioned that you were able to do the first part so you are essentially only asking about the second part. The following example should help get you pointed in the right direction:



                          >>> planets = ['Mercury','Venus','Earth','Mars','Neptune','Jupiter','Saturn','Uranus']
                          >>> vowels = ('a','e','i','o','u')
                          >>> name_counts = []
                          >>> for name in planets:
                          ... count = sum([1 for letter in name if letter.lower() in vowels])
                          ... name_counts.append((name,count))
                          ...
                          >>> print(sorted(name_counts, key=lambda x: x[1]))
                          [('Mars', 1), ('Mercury', 2), ('Venus', 2), ('Earth', 2), ('Saturn', 2), ('Neptune', 3), ('Jupiter', 3), ('Uranus', 3)]





                          share|improve this answer





























                            0












                            0








                            0







                            You mentioned that you were able to do the first part so you are essentially only asking about the second part. The following example should help get you pointed in the right direction:



                            >>> planets = ['Mercury','Venus','Earth','Mars','Neptune','Jupiter','Saturn','Uranus']
                            >>> vowels = ('a','e','i','o','u')
                            >>> name_counts = []
                            >>> for name in planets:
                            ... count = sum([1 for letter in name if letter.lower() in vowels])
                            ... name_counts.append((name,count))
                            ...
                            >>> print(sorted(name_counts, key=lambda x: x[1]))
                            [('Mars', 1), ('Mercury', 2), ('Venus', 2), ('Earth', 2), ('Saturn', 2), ('Neptune', 3), ('Jupiter', 3), ('Uranus', 3)]





                            share|improve this answer















                            You mentioned that you were able to do the first part so you are essentially only asking about the second part. The following example should help get you pointed in the right direction:



                            >>> planets = ['Mercury','Venus','Earth','Mars','Neptune','Jupiter','Saturn','Uranus']
                            >>> vowels = ('a','e','i','o','u')
                            >>> name_counts = []
                            >>> for name in planets:
                            ... count = sum([1 for letter in name if letter.lower() in vowels])
                            ... name_counts.append((name,count))
                            ...
                            >>> print(sorted(name_counts, key=lambda x: x[1]))
                            [('Mars', 1), ('Mercury', 2), ('Venus', 2), ('Earth', 2), ('Saturn', 2), ('Neptune', 3), ('Jupiter', 3), ('Uranus', 3)]






                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Mar 27 at 1:32

























                            answered Mar 27 at 1:07









                            DodgeDodge

                            1,6011 gold badge11 silver badges24 bronze badges




                            1,6011 gold badge11 silver badges24 bronze badges






























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Stack Overflow!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55368220%2fhow-to-display-the-number-of-vowels-in-a-list%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                                SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

                                은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현