List Comprehension in Python

Поділитися
Вставка
  • Опубліковано 24 сер 2024

КОМЕНТАРІ • 49

  • @harishmahajan6845
    @harishmahajan6845 Рік тому +17

    home work problem = using for loop list print First char in Capital.
    this is by using list comprehension
    animals = ['lion','tiger','monkey','elephant','frog']
    filtered_animal = [animal.title() for animal in animals]
    print(filtered_animal)

  • @dsalgos
    @dsalgos Місяць тому +2

    You must be very good at planning things !! Your videos are extremely organized !! Watching like a Web series !!

  • @CHOMUGMING
    @CHOMUGMING Рік тому +13

    Your teaching language owesom 😅 sometimes I forget that you are speaking in English 😅

  • @izainonline
    @izainonline 2 місяці тому +2

    This concept can be used in data scrapping like extracting the data and saving in j.names[ ]
    My suggestion is to give examples of code can be used in what scenarios so that interest and concept will be strong for new learners.

    • @asahade3847
      @asahade3847 22 дні тому

      @@izainonline hello . Do you have a Channel..? Thanks for the tip.

  • @Arian003Mi
    @Arian003Mi 2 місяці тому

    Wow man you explain programming best out of other youtubers ngl

  • @mohammedrezk8072
    @mohammedrezk8072 Рік тому +7

    Thx and my answer is
    filtered_animals= [x.title() for x in animals ]
    please let me what's correct answer..

  • @jingersatuh6322
    @jingersatuh6322 6 місяців тому +1

    This is a hard topic, but well explained.

  • @Harbingersknight21
    @Harbingersknight21 4 місяці тому +1

    Homework question answer -:
    animals = ['lion' , 'tiger' , 'monkey' , 'elephant' , 'frog']
    filtered_animals=[animal.title() for animal in aminals]
    print(filtered_animals)

  • @pgkgaming4229
    @pgkgaming4229 4 місяці тому

    Osm teaching nice explanation ❤❤❤

  • @suchetrana156
    @suchetrana156 9 місяців тому +1

    ani = ['lion', 'tiger', 'monkey','elephant']
    ani_2 = [x.title() for x in ani ]
    ani_2

  • @II_Emilia_II
    @II_Emilia_II 8 місяців тому

    Very helpful, thanks :)

  • @jereddymanojkumar3830
    @jereddymanojkumar3830 Рік тому +9

    animals =[ 'lion' ,'tiger', 'monkey', 'elephant', 'frog']
    filtered_animals=[ animals.tittle() for animal in animals ]
    filtered_animals=['Lion', 'Tiger', 'Monkey', 'Elephant', 'Frog']
    When we use tittle() method on string it will do each letter of first character will upper case remaining lower case and it will return string and it doesn't take parameters

  • @santoshluhar2626
    @santoshluhar2626 Рік тому +5

    [animal.title() for animal in animals]

    • @tayyab.sheikh
      @tayyab.sheikh 2 місяці тому +1

      I was gonna comment the same!

  • @RahulSingh-qs9ed
    @RahulSingh-qs9ed 5 місяців тому +1

    animal = ["lion","tiger","monkey","elephent","frog"]
    Fanimal = [a.title() for a in animal]
    print(Fanimal)

  • @asahade3847
    @asahade3847 Місяць тому

    What is the animal.title function and why followed by the ()..
    Thanks

    • @jsmphompho8052
      @jsmphompho8052 23 дні тому

      it's a string method used to convert a first character of a string to an uppercase then the rest are converted to lowercase characters

  • @Raja-tt4ll
    @Raja-tt4ll 3 місяці тому

    Super

  • @mdshadabanwer3150
    @mdshadabanwer3150 18 днів тому

    filtered_animals=[animal.title() for animal in animals]

  • @Yomdheal
    @Yomdheal 3 місяці тому

    list(print("animal.title()" for animal in animals))

  • @dsalgos
    @dsalgos Місяць тому

    filtered_animals = [value.title() for value in animals]

  • @JignaPatel-q7h
    @JignaPatel-q7h Місяць тому

    i'm not able to run list comprehension example .

  • @archanavennela8737
    @archanavennela8737 2 місяці тому

    Sir can we have python DSA classes please

  • @AbdulDanmalan
    @AbdulDanmalan 10 місяців тому

    filtered_animals = [ "animal title() " for animal in animals]

  • @user-ei1xi7ns1u
    @user-ei1xi7ns1u 6 місяців тому

    #list comprehension(conv. from for loop), shortened list
    animals = ['lion', 'tiger', 'python']
    filtered_animals=[animal.title() for animal in animals]
    print(filtered_animals) # Output: ['Lion', 'Tiger', 'Python']

  • @kingR-p6n
    @kingR-p6n Місяць тому

    animals = ["lion", "tiger", "elephant", "monkey", "frog"]
    animals_2 =[animal.title() for animal in animals]
    print(animals_2)

  • @Movie_in_hindi8
    @Movie_in_hindi8 5 місяців тому

    #Homework
    filtered_animals = [animal.title() for animal in animals]
    print(filtered_animals)

  • @jingersatuh6322
    @jingersatuh6322 6 місяців тому

    >>> animals = ["lion", "tiger", "monkey", "elephant", "frog"]
    >>> filtered_animals = [animal.title() for animal in animals]
    >>> filtered_animals
    ['Lion', 'Tiger', 'Monkey', 'Elephant', 'Frog']

  • @zokbrains1129
    @zokbrains1129 2 місяці тому

    >>>animals = ['lion', 'tiger', 'monkey', 'elephant', 'frog']
    >>>Filtered _animals = [animal_title() for animal in animals]
    >>>Filtered _animals
    ['lion', 'tiger', 'monkey', 'elephant', 'frog']
    >>>

  • @somanathking4694
    @somanathking4694 8 місяців тому

    animal = [i.title() for i in animals]
    animal
    ['Lion', 'Tiger', 'Monkey', 'Elephant', 'Frog']

  • @lionelfaith3646
    @lionelfaith3646 10 місяців тому

    animals= ['lion','tiger','monkey','elephant','frog']
    filtered_animals=[animal.title() for animal in animals]
    print(filtered_animals)
    output: ['Lion', 'Tiger', 'Monkey', 'Elephant', 'Frog']

  • @sigmatronX
    @sigmatronX 4 місяці тому

    animals = ['lion', 'tiger', 'monkey', 'elephant', 'frog']
    filtered_animals = [ ]
    filtered_animals = [name.title( ) for name in animals]
    print(filtered_animals)

  • @nithishm6619
    @nithishm6619 7 місяців тому

    animals = ['lion','tiger','monkey']
    f_animals = [animal for animal in animals]
    print(f_animals)

  • @chriswa3346
    @chriswa3346 Рік тому +3

    First

  • @abhasjaiswal2384
    @abhasjaiswal2384 8 місяців тому

    animals = ['lion', 'tiger', 'monkey', 'elephant', 'frog']
    filtered_animals = [animal.title() for animal in animals]

  • @NormieDead
    @NormieDead 5 місяців тому

    Ans:
    ```
    animals = ['lion', 'tiger','monkey','elephant','frog']
    filtered_animals = [animal.title() for animal in animals ]
    print(filtered_animals)
    ```

  • @madhav.s2707
    @madhav.s2707 17 днів тому

    name for name in names if "J" in name... You could think of anything more complex🤣

  • @Lalitamm
    @Lalitamm 10 місяців тому

    animals = ['lion', 'tiger', 'monkey', 'elephant', 'frog']
    filtered_animals = [animal.title() for animal in animals ]
    print(filtered_animals)

  • @lingeshmaster3113
    @lingeshmaster3113 26 днів тому

    filtered_animals = [animal.title() for animal in animals]

  • @kingR-p6n
    @kingR-p6n Місяць тому

    animals = ["lion", "tiger", "elephant", "monkey", "frog"]
    animals_2 =[animal.title() for animal in animals]
    print(animals_2)

  • @peakyblinders3365
    @peakyblinders3365 Місяць тому

    filtered_animals = [animal.title() for animal in animals]

  • @stellamargy8075
    @stellamargy8075 11 місяців тому +1

    filtered_animals=[animal.title() for animal in animals ]

  • @mohammedzakidarga4802
    @mohammedzakidarga4802 Місяць тому

    filtered_animals = [animal.title() for animal in animals]

  • @joshualeblanc1276
    @joshualeblanc1276 4 місяці тому

    filtered_animals = [animal.title() for animal in animals]

  • @deviprasadpandey
    @deviprasadpandey 7 місяців тому

    filtered_animals=[animal.title()for animal in animals]