Nested loops in Python are easy ➿

Поделиться
HTML-код
  • Опубликовано: 3 фев 2025

Комментарии • 170

  • @BroCodez
    @BroCodez  2 года назад +105

    # nested loop = A loop within another loop (outer, inner)
    # outer loop:
    # inner loop:
    rows = int(input("Enter the # of rows: "))
    columns = int(input("Enter the # of columns: "))
    symbol = input("Enter a symbol to use: ")
    for x in range(rows):
    for y in range(columns):
    print(symbol, end="")
    print()

    • @mondlistyleman9389
      @mondlistyleman9389 Год назад +5

      You're my hero... Love from South Africa :)

    • @icytur5686
      @icytur5686 4 месяца назад

      There’s a little typo in the code, columns go horizontal so the outer loop in this case represents the columns and inner loop is the rows

  • @Lex_Marion
    @Lex_Marion Год назад +538

    I don't know why but my brain really, REALLY wants to overthink both for loops and nested loops. They're really simple concepts but something always gets wonky in the monkey wires. This was a great video, really needed something to explain it in the most babymode 5 year old way, thank you

    • @gerardogodinez6919
      @gerardogodinez6919 Год назад +26

      Same happens to me

    • @sakshampokhrel42
      @sakshampokhrel42 Год назад +7

      Its a completely opposite for me tho i need more in depth explanation

    • @mello4392
      @mello4392 Год назад +10

      I thought I was the only one

    • @IMDash_freak002
      @IMDash_freak002 Год назад +1

      Yeah me too😢

    • @Frail-pg8xt
      @Frail-pg8xt Год назад +1

      Same condition for everyone else. No one just realises it

  • @francisjacquart9618
    @francisjacquart9618 Год назад +22

    THAT IS SO WELL THOUGHT OUT! BRILLIANT! AND I AM STARTING TO UNDERTAND HOW PROGRAMMERS THINK AND DEVELOP THEIR PROGRAMS! THANK YOU SO MUCH FOR ALL YOUR TUTORIALS!

    • @maskie.maskie
      @maskie.maskie Год назад +1

      U are the best🥲, u are supposed to be a lecture😏

  • @cdkw8254
    @cdkw8254 Год назад +54

    Bro, you saved me ass, I was gonna fail for sure but you absolute ultimate gigachad saved my. Thank you King. You dropped this 👑

  • @harleenkaur2096
    @harleenkaur2096 2 года назад +23

    Thank you much
    This is the first time I have understood nested loops, pattern after watching so many videos
    God bless
    Please keep making more videos on programming

  • @jaspersumugat6951
    @jaspersumugat6951 2 года назад +11

    This is very clever and give me a better understanding in nested loop

  • @Narree-61
    @Narree-61 6 месяцев назад +1

    This guy is one of my favorite people on Earth. I don't even know who you are but you are 100% a king

  • @rossmarvin6078
    @rossmarvin6078 2 месяца назад

    Aaah!!! It's all clicked in my head now. Thanks man!

  • @jeiddoromal4804
    @jeiddoromal4804 8 месяцев назад +1

    clear explanation, helped and saved my brain from overthinking

  • @krosarian
    @krosarian Год назад +3

    took me about an hour but finally I understand nested loops, thank you Bro Code

    • @NorfaizahMatLui
      @NorfaizahMatLui Год назад

      3 days now, still dont fully understand it

    • @krosarian
      @krosarian Год назад +8

      @@NorfaizahMatLui take your time, what worked for me was writing it on a whiteboard, and trying to explain it with my own words, if you think about it it's like multiplication:
      For n in range(3)
      For z in range(5)
      Print("hello")
      The first for loop will tell you how many times the next loop will be done, in this case 3, and then the second loop, will print 5 "hello":
      Hello hello hello hello hello
      Hello hello hello hello hello
      Hello hello hello hello hello
      You printed 5 hello's, 3 times

    • @banane442
      @banane442 Год назад +1

      @@krosarian that´s actually a pretty good. thx man

    • @SnPnibba
      @SnPnibba 11 месяцев назад

      @@krosarian Buddy to print what you wrote:
      for i in range(3):
      for k in range(5):
      print("hello", end="")
      print()
      Hope yer fine.

  • @divya264
    @divya264 4 месяца назад

    you are a blessing to me dude !

  • @gamisr2848
    @gamisr2848 Год назад

    First semester CS student. Nested loops confused the hell out of me in class last week. This video helped clear some of the confusion. Much appreciated!

    • @quonkylops
      @quonkylops Год назад +1

      Also a first semester CS student, was totally lost. Hoping this video helps. Will watch when I get home from my lecture.

  • @muhammadabdullahwaseem3040
    @muhammadabdullahwaseem3040 Год назад +2

    I have my a levels computer science exam tomorrow and you just saved my life

  • @admo001
    @admo001 Год назад +1

    Thanks bro, you explain them really well

  • @yonisapir6270
    @yonisapir6270 2 года назад +5

    Perfectly explained, thank you!

  • @thedeparted_one
    @thedeparted_one 2 года назад +1

    Bro, may I say you have such a soothing and beautiful voice? 🤗

  • @calculuslifer4024
    @calculuslifer4024 2 года назад +4

    Now I understand nexted loop better👏✔️

  • @CarlosLopez-mx8hq
    @CarlosLopez-mx8hq 7 месяцев назад

    Dude i fking love u, ur content is outstanding

  • @deepakthakkur5627
    @deepakthakkur5627 2 месяца назад +1

    i dont know english very well in comparison with hindi but your way of explain such a nice and very simple to understand that i understood it better than in hindi

  • @mariakoszalin
    @mariakoszalin 7 месяцев назад

    best explanation of nested loops out there

  • @RominiyiOmodona
    @RominiyiOmodona 7 месяцев назад +1

    Thanks for the explanation really needed it I was literally going mad trying to understand it on my own not know that it is not that deep

  • @KrishKala1109
    @KrishKala1109 Месяц назад

    amazing videos, really helpful for GCSE computer science

  • @babludas007
    @babludas007 Год назад

    You entirely clear my concept ... thanks alot bro 😭😭🤌

  • @markrose805
    @markrose805 Год назад

    You’re awesome man! Thanks

  • @ch_dave19
    @ch_dave19 2 года назад +1

    Thank you bro for all your videos. I Iearnt java and javascript extensively through your videos.

  • @slipperysoap-bob
    @slipperysoap-bob 9 дней назад

    great video I learnt something

  • @dipikapandya4622
    @dipikapandya4622 11 месяцев назад +2

    Bro saved me from failing in my class 11th practical exams 🙏🏽🙏🏽🙃

  • @script_tester-1
    @script_tester-1 Месяц назад

    best lesson ever!

  • @manansharma5686
    @manansharma5686 4 месяца назад

    great video bro .love from INDIA🧡🤍💚

  • @A1NTT
    @A1NTT Год назад

    I have watched multiple videos, trying to understand nested loops and this video finally made sense to me! Thanks for breaking this down in such an easy way.

  • @MrSimonmartinlee
    @MrSimonmartinlee 11 месяцев назад

    excellent vid. really well explained. thanks

  • @bobaayla
    @bobaayla Год назад

    This is a life saver video I have my exam tomorrow so thank u so much

  • @adivhahoratshimolo2671
    @adivhahoratshimolo2671 11 месяцев назад

    You are the best!!!!!

  • @luuksemmekrot4509
    @luuksemmekrot4509 4 месяца назад

    Bro youre amazing thank you

  • @koreishite
    @koreishite 4 месяца назад

    Super content and editing

  • @cartoon_station123
    @cartoon_station123 Год назад +1

    Thank you sir for your help..

  • @J2128H
    @J2128H Год назад

    awesome content as always, thanks Bro!👌

  • @Muhammadbilalnawaz-f6r
    @Muhammadbilalnawaz-f6r Год назад +1

    Thank you so much sir

  • @Compuscience-Python-Prog-Exps
    @Compuscience-Python-Prog-Exps Год назад

    Thank so very much for your help on leaning Python .. Great, to the point Teacher.

  • @bekturasanbekov1979
    @bekturasanbekov1979 Год назад +1

    Thx 4 vid bro !

  • @MESHALGAMEZ
    @MESHALGAMEZ 11 месяцев назад

    Thx bro for the good explanation I have an exam tomorrow and I didn’t understand nested loops bcz the explanation in the digital book that the school gave me was CONFUSING AND COMPLICATED

  • @anandh7094
    @anandh7094 Год назад

    thanks for your explanation it's really helpful ☺

  • @destinydie
    @destinydie 7 месяцев назад

    Thanks for the wonderful video...

  • @ugonkem9878
    @ugonkem9878 Год назад +1

    Thank you so much for this

  • @KvintKek
    @KvintKek Год назад

    Wow !! super expalination !@

  • @Louviewtube
    @Louviewtube Год назад

    Brilliant. Thank you.

  • @mohammadsahirrangrez8525
    @mohammadsahirrangrez8525 3 месяца назад

    bro you are my G

  • @umaydilarakuscu642
    @umaydilarakuscu642 2 года назад +1

    you're awesome

  • @omaralbrkaui2013
    @omaralbrkaui2013 Год назад

    man i love you thx

  • @K4113B4113
    @K4113B4113 5 месяцев назад

    Man I could barely understand a word my programmer teacher said during the entire semester. He had this really thick south-asian accent. Took me several lessons to understand that he was saying "unicode" and not "unicorn", let alone understanding what unicode is. The language was Java which is a bit unintuitive compared to Python and the course book was this 600 pages, dull, black and white textbook that I couldn't muster any motivation to read multiple pages out of.
    Somehow I managed to get the highest grade in Programming 101 and the second highest in Programming 102 (I think the teacher was overly nice and just gave out good grades). The end result was that I didn't feel like I understood anything about programming whatsoever despite what my grade sheet said. For some reason I've had a really negative or hopeless attitude towards programming ever since. What I'm trying to say is: these videos are great.

  • @bodyart1460
    @bodyart1460 2 года назад +1

    very helpful thanks

  • @alivee9496
    @alivee9496 5 месяцев назад

    you are awesome

  • @Raja-tt4ll
    @Raja-tt4ll Год назад

    Very nice

  • @reincarnationofthelightking
    @reincarnationofthelightking 5 месяцев назад

    ahhh this is soo baffling, my brain cannot comprehend this idea

  • @johnbainbridge1931
    @johnbainbridge1931 Год назад +1

    I finally see the light!😀

  • @krithika417
    @krithika417 4 месяца назад +2

    Yes this is easy but there are programs that go like the output should be like the following
    *
    * * *
    * * * * *
    * * *
    *
    or like
    *
    * *
    * *
    * *
    *
    can you make a video on how to do them please

  • @chalanagimhana8275
    @chalanagimhana8275 Год назад

    you are the best

  • @robertfaney4148
    @robertfaney4148 10 месяцев назад

    do you have a matrix done ? That would be great !

  • @Mario-if5tl
    @Mario-if5tl Год назад

    Good job 👍

  • @LoyisoMsweli
    @LoyisoMsweli 5 месяцев назад +1

    I clearly understand now but I tried it several times, it gives me syntax error I do not know what is wrong

  • @raxivy7878
    @raxivy7878 Год назад

    THANK YOU SO MUCH

  • @Zenderlife
    @Zenderlife 2 месяца назад

    idk why i was so confused on nested loops to start out with now

  • @MrP-jg3cc
    @MrP-jg3cc Год назад +7

    Hey bro I'm new to python, I just want to kick start my career I'm 23 now, is it ok to learn python from basics., Bcz I feel aged for programming..

    • @hanshalili174
      @hanshalili174 9 месяцев назад +2

      It’s never too late

    • @Negi155
      @Negi155 4 месяца назад +1

      Did you got it bro?

  • @InfinityGaming00786
    @InfinityGaming00786 4 месяца назад

    "SAVED, I'M SAVED"

  • @MrDarkplace22
    @MrDarkplace22 8 месяцев назад

    this guy tptally sounds like ryan george from pitch meeting , also thanks for your video made a complex topic so simple

  • @ethana1
    @ethana1 9 месяцев назад

    v v good. ty ❤

  • @xudayfitechofficial
    @xudayfitechofficial 2 года назад +2

    respect Teacher.
    @Bro Code

  • @dodouniquelife9725
    @dodouniquelife9725 Месяц назад

    ❤ Thank You Very Much ❤

  • @artemblinkov2241
    @artemblinkov2241 Год назад

    Really loved the explanations, thanks! One question, how would the code look like if I wanted to make a triangle tho?

  • @Kerem-IIII
    @Kerem-IIII Год назад

    I didn't like the appearance of having a period after the last number in the iteration, so I wanted to change how it looks. But I also wanted to avoid hard-coding it to be the exact number '9'. Here is the solution I came up with, using the str.join() method:
    for x in range(3):
    sequence = range(1, 10)
    last_number = list(sequence)[-1]
    numbers = [str(y) if y != last_number else str(y) for y in sequence]
    print(".".join(numbers))

  • @Dm__0612
    @Dm__0612 2 года назад +1

    Thank you❤

  • @jinkazama3647
    @jinkazama3647 Год назад +1

    Can u make it in one line please?

  • @kqwl
    @kqwl Год назад

    Thank you

  • @manuelsantosjr9822
    @manuelsantosjr9822 Год назад

    Hey Bro code, do you have an example of a text based game in python??

  • @AyushSharma-cs8yv
    @AyushSharma-cs8yv 3 месяца назад

    Thankyou❤

  • @billythenarwhal1579
    @billythenarwhal1579 11 месяцев назад

    So I'm doing exactly this but for some reason it's shorting me a symbol at the end.

  • @DipanshuAgarwal-q2q
    @DipanshuAgarwal-q2q 6 месяцев назад

    Bro pls tell which site u use

  • @pubudinijayawardana3801
    @pubudinijayawardana3801 8 месяцев назад

    sir how can I use this expression in python for nested loops? val= int(input()) inputs are 2 and 5. and output should be * mark as rectangle shape. Please explain. Thank you.

  • @extendedsomeone
    @extendedsomeone 2 месяца назад

    #shapemakerproject ➿
    rows = int(input("Enter the number of rows :"))
    columns = int(input("Enter the number of columns :"))
    symbol = input("Enter a symbol to use :")
    for x in range(rows) :
    for y in range (columns):
    print(symbol, end="")
    print()

  • @ExcelTutorials1
    @ExcelTutorials1 Год назад

    Very well explained, thank you!

  • @nfsheat1456
    @nfsheat1456 11 месяцев назад

    damn ur awesome

  • @mavatrollinggarage4431
    @mavatrollinggarage4431 2 года назад +1

    Tq so much

  • @Jggapp016
    @Jggapp016 2 года назад +18

    Can you make a tutorial how to delete system32 with python ?

    • @BroCodez
      @BroCodez  2 года назад +20

      no lol

    • @Jggapp016
      @Jggapp016 2 года назад +5

      @@BroCodez Ok =l

    • @ElwinJoby
      @ElwinJoby 2 месяца назад +1

      Here is the code. Replace the placeholders with your file name and path import os
      def delete_test_file(file_path):
      try:
      if os.path.exists(file_path):
      os.remove(file_path)
      print(f"File {file_path} deleted.")
      else:
      print(f"File {file_path} does not exist.")
      except Exception as e:
      print(f"Error: {e}")
      # Test path to a non-essential file
      delete_test_file("C:/path/to/non/critical/test/file.txt")

    • @Jggapp016
      @Jggapp016 2 месяца назад +1

      @@ElwinJoby Hey thank you !🥰🥰

    • @dankbruhnco1765
      @dankbruhnco1765 2 месяца назад +1

      ​@@ElwinJoby What have you done

  • @Mr.chunker
    @Mr.chunker 2 месяца назад

    I love you dawg not in a gay way but this vid saved my ass I was having trouble with for loops cause it was a bit confusing to me, then I saw this vid and I understand now. Thanks you got a new subscriber

  • @sumfatt640
    @sumfatt640 Год назад

    thnx , with anki flashcards would be cool to memorize

  • @RameshKumar-ng3nf
    @RameshKumar-ng3nf 11 месяцев назад

    Such a beautiful explanation Sir. Thanks a lot for sharing making it easy to understand for beginners.

  • @ramazanyetismis192
    @ramazanyetismis192 Год назад

    after first loop can we write print(symbol * columns ) and finish the code ?

  • @moralfuxery
    @moralfuxery Год назад

    My thing and im in my 3rd werk for python is when I'm reading or watching this material i understand it, but i have an issue seeifn where you use it. Maybe this comes along once you understand all the fundamentals concretely bc i sure as hell don't yet. But this leads to massive overthinking on my part.
    Like, i have a simple site written in simple html/css. I have made a database in docker with MSSQL, and i want to make a python application to get the data from the DB and display it on the webpage. In very generic terms this is the "stack" im looking for no?

  • @ElyamineFahardine-bi8md
    @ElyamineFahardine-bi8md Год назад

    Which app do u use to program?

    • @AyuPlus
      @AyuPlus 10 месяцев назад +1

      PyCharm

  • @_GRBL
    @_GRBL 2 года назад +1

    Wher full rust tutorial

  • @fabianodeoliveira7
    @fabianodeoliveira7 Год назад +1

    haha, valeu amigo.
    Estou fazendo um curso qui no Brasil usam essa refêrencia para ensinar for in range.
    Vou ver mais aulas, não compreendo inglês, mas entendo o código.

  • @manisarijal2146
    @manisarijal2146 Год назад

    ❤❤😊😊

  • @smedge4048
    @smedge4048 Год назад

    X is a counter. What is a counter?

    • @AyuPlus
      @AyuPlus 10 месяцев назад

      Watch the video on for loops

  • @karnikabaroniya
    @karnikabaroniya Год назад

    can someone tell me how to get this type of window in python with the program result at the bottom

  • @merwanmohammed8332
    @merwanmohammed8332 Год назад

    i think you mistaken row for column and column for row

  • @AK-Star007
    @AK-Star007 2 года назад +2

    end="/t"
    Will make your result like a table

    • @cdkw8254
      @cdkw8254 Год назад

      I think you mean \t

  • @mythicpulse-i9o
    @mythicpulse-i9o Год назад +1

    a loop inside of an another loop outer loop inner loop

  • @jiobrando
    @jiobrando 2 года назад +1

    Bro can you make a Kotlin tutorial?
    I crash course your Java andddddd employers seeks Kotlin....

  • @saiguyplays4952
    @saiguyplays4952 Год назад

    bro which idle do u use

    • @AyuPlus
      @AyuPlus 10 месяцев назад

      Pycharm

  • @Traag96
    @Traag96 Год назад +1

    Chad 🗿 explanation