Python Conditional Statement inside a for Loop

Поділитися
Вставка
  • Опубліковано 14 чер 2019
  • Putting an if-else conditional statement inside a for loop to repeate a specified amount of times and using a break statement.
  • Навчання та стиль

КОМЕНТАРІ • 10

  • @beckybonny7552
    @beckybonny7552 Рік тому +4

    This was exactly what I was looking for. Perfectly explained. Thank you so much!

  • @vanshjain460
    @vanshjain460 Рік тому

    I hve been searching for an explanation all over UA-cam urs was the precise solution and understanding to my problem. Thankyou

  • @HeroKat_3000
    @HeroKat_3000 Рік тому +1

    Thanks bro, I am a student and just started python and was doing a personal programming and your video helped a lot, thanks

    • @sayaankhan3484
      @sayaankhan3484 Рік тому +1

      Stuart Davey is that you 😭😭😭 this sounds like Davey can't lie.

  • @geek-diallo4811
    @geek-diallo4811 2 роки тому

    Nice video. You deserved so many likes and subscribers. 👍👍 Keep it up. I’m one of your subscribers now

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

    Thank you! This helps me a lot!

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

    Yeah but isn't it a bad practice to use breaks to exit loops? Isn't the "correct" way setting up a exit condition within the loop (like int i < 3) that exits you instead?

    • @homastudio45
      @homastudio45  9 місяців тому

      I agree, its more efficient to use a while loop and a condition which I mention near at the end of the video. For this video, I was just introducing how the break works, but necessarily the best or only option.

  • @techjhelo9698
    @techjhelo9698 Рік тому

    Thanks bro

  • @lilyfullery4779
    @lilyfullery4779 Рік тому +2

    password = input("enter thr password : ")
    for i in range(2):
    if password != "python":
    print ( "wrong password remain attemp ", 2-i)
    password = input("enter thr password : ")
    elif password =="python":
    print('WELCOME')
    break