How to use a for loop to repeat work - Swift for Complete Beginners

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

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

  • @berrakylmaz1550
    @berrakylmaz1550 3 года назад +5

    you are a real swiftie

  • @ask4applewho842
    @ask4applewho842 2 года назад +3

    how these videos have only 2k views !!! thanks man

  • @AngryAyrab
    @AngryAyrab 22 дня назад

    Had to watch this a couple of times and go over the reading to actually grasp my limited understanding of it.

  • @1ssas11saa
    @1ssas11saa 3 года назад +1

    nice

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

    Why doesn’t the _ loop print out the entire string 5 times? I.e Haters gonna hate Haters gonna hate…etc?

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

      lyric += " hate" just adds the word hate to the already existing string 'Haters gonna'. and it runs 5 times. With each run, it adds the word hate to the new string and stores it. So the first time it runs, the string becomes 'Haters gonna hate'. on the second run, it adds the word hate to the last stored string, the new string becomes "Haters gonna hate hate" and so on. Once the fifth run is executed, it prints the final string.
      You can try and put the print statement inside the loop body and will see that it does print the newly formed string with each new iteration.

  • @edgar_roca
    @edgar_roca 6 месяцев назад

    I don't understand how in the nested loop the iteration repeats the number "1" a total of "12" times and the number "2" and so on. I'm breaking my head. That's the only part I don't get.

    • @yuvrajnarewade4684
      @yuvrajnarewade4684 6 месяцев назад

      @edgar_roca:
      At the beginning, i =1 (to print 1s table).
      Then j for loop execution starts. Loop variable is j whose value is 1 at the beginning. Now i=1, j =1, in this first iteration 1 x 1 is 1 is printed. J increments to 2. In the second iteration of the j loop, i=1, j=2. Hence it prints 2 x 1 is 2. For the third iteration of the j loop, i=1, j=3. Hence it prints 3 x 1 is 3, until 12 x 1 = 12. Once 12 iterations of the j loop are completed, it comes out of loop, increment i to 2 and repeats j for loop with i= 2. Hence 2's table. I believe this should help.

  • @ilgaralizada7206
    @ilgaralizada7206 3 года назад +3

    Taylor Swift should lean Swift))

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

      Too bum for that

  • @Toxicflu
    @Toxicflu 2 года назад

    that was swift