List Comprehensions | Python | Basic Data Types | HackerRank

แชร์
ฝัง
  • เผยแพร่เมื่อ 5 ก.ย. 2024

ความคิดเห็น • 35

  • @jaspinho
    @jaspinho 4 ปีที่แล้ว +12

    I was looking for an explanation for this problem and you did it perfectly. Really Thank you for the explanation.

  • @Aestheticdeeps
    @Aestheticdeeps 4 หลายเดือนก่อน +2

    thank you sir well explained

    • @codingcart
      @codingcart  4 หลายเดือนก่อน

      Glad it helped😊. Please do share with your friends too😊

  • @deeptisingh904
    @deeptisingh904 3 ปีที่แล้ว +4

    you really explained it very well.

  • @paruluniyal2305
    @paruluniyal2305 4 ปีที่แล้ว +3

    Nicely explained 👍

  • @sudarsanan6700
    @sudarsanan6700 3 ปีที่แล้ว +1

    Thanks sir very helpful video .I am a begginer this video helped me a lot to understand list comprehension.

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Glad to hear that

  • @MdRizwanRabbani
    @MdRizwanRabbani 4 ปีที่แล้ว +3

    Good info 👍

    • @codingcart
      @codingcart  4 ปีที่แล้ว

      Glad it was helpful!

  • @abhishekbhat3152
    @abhishekbhat3152 3 ปีที่แล้ว +2

    simple and nice explainiation

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Thanks for liking

  • @zaveriakhulsoom8470
    @zaveriakhulsoom8470 3 ปีที่แล้ว +1

    explained very well, awesome thank you, do more videos.

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Thanks, will do!

  • @janushaik976
    @janushaik976 ปีที่แล้ว +1

    ur explanation is awesome sir thank you

    • @codingcart
      @codingcart  ปีที่แล้ว

      Glad you liked it. Do share with your friends too😊

    • @janushaik976
      @janushaik976 ปีที่แล้ว

      Sure 👍

  • @himanshutondwal7900
    @himanshutondwal7900 2 ปีที่แล้ว +1

    Thankyou you explained it very well

    • @codingcart
      @codingcart  2 ปีที่แล้ว

      Glad you liked it 😊

  • @MrMukulpandey
    @MrMukulpandey 2 ปีที่แล้ว +1

    Great 👌

    • @codingcart
      @codingcart  2 ปีที่แล้ว +1

      Glad you liked it 😊.Do share with your friends too 🙂

  • @fersalamanca2606
    @fersalamanca2606 2 ปีที่แล้ว

    This is very well explained, though the only thing I don’t get is why when you create the ranges you add 1 to the variable, e.g. range(x + 1)

    • @trojan6741
      @trojan6741 2 ปีที่แล้ว +3

      if we would have written range(x) then range function will work for x-1 times. eg. for i in range(10) will return [0,1,2,3,4,5,6,7,8,9]

  • @anujgupta7749
    @anujgupta7749 3 ปีที่แล้ว +1

    Good Job Brother, but why you don't use append in List Comprehensions?

  • @jaganchowhaan9648
    @jaganchowhaan9648 2 ปีที่แล้ว +1

    Cool explanation Bro ..Thanks and keep sharing

    • @codingcart
      @codingcart  2 ปีที่แล้ว

      Thanks and welcome

  • @Cloudxxx23
    @Cloudxxx23 10 หลายเดือนก่อน

    Hi. Why it needs to add 1?

  • @ragnarlodhbrok1684
    @ragnarlodhbrok1684 ปีที่แล้ว

    y u didnt use append in list comprehension?

  • @harikrishnas5743
    @harikrishnas5743 3 ปีที่แล้ว

    Why cant i get the output when i do the same code in my normal ide ? Explanations anyone?

    • @nombuso4162
      @nombuso4162 3 ปีที่แล้ว

      Because HackerRank has shortcuts especially when it comes to the input

  • @nepalrameshwor1540
    @nepalrameshwor1540 2 ปีที่แล้ว

    why this is wrong?
    new_list = [ [ i , j , k ] for (i , j , k) in range (x+1, y+1, z+1) if (i + j + k ! = n)]

    • @balrajsinghbhamra9678
      @balrajsinghbhamra9678 2 ปีที่แล้ว +3

      range function simply doesn't work like the way you have coded it.
      Basic syntax of range is range(starting value, ending value, steps) and that is what you are doing here.
      Also, 'for' statement doesn't take multiple variables like that for answering the question in the video.
      For applying your logic properly, you can use a library called 'itertools'.
      A proper solution will be as follows:
      import itertools
      res = 0
      x=1
      y=2
      z=1
      n=3
      res=[[i,j,k] for i,j,k in itertools.product(range(x+1),range(y+1),range(z+1)) if i+j+k!=n]
      print(res)
      In the above code, I have used the product method that returns the cartesian products of the iterables defined inside it's bracket.
      You can visit the site I am mentioning for knowing more about this method.
      www.geeksforgeeks.org/python-itertools-product/
      happy coding!

  • @nikhilsahijwani3228
    @nikhilsahijwani3228 3 ปีที่แล้ว

    LIST COMPREHENSION
    not multiple for loops