"break" & "continue" Statements in Python #10

แชร์
ฝัง
  • เผยแพร่เมื่อ 23 ม.ค. 2025

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

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

    🔥 Learn Python with a more hands-on experience with Programiz PRO-interactive lessons, quizzes & challenges.
    Try Programiz PRO: bit.ly/right-python

  • @kismet4904
    @kismet4904 4 ปีที่แล้ว +16

    Loving this series, I have learned a lot in such a short amount of time :D keep it up!

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

    To be Honest i was very very scared of programming, i am watching your Videos since last week and now i am writing few lines of codes just because of you.
    Thank you so much
    Your are diong a good job

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

    The best Channel to learn python

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

    just one word- Awesome! Your channel is a very big help to me. Thanks :)

  • @KulbirAhluwalia
    @KulbirAhluwalia 4 ปีที่แล้ว +17

    Everything is perfect, just keep your head stable when you speak. Thank you.

  • @ramraj4047
    @ramraj4047 2 ปีที่แล้ว +18

    languages=["python","java","swift","c","c++"]
    for i in range (len(languages)):
    if(i==2 or i==4):
    continue
    print(languages[i])

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

      I've been treing this code for several times, it doesn't skip the languages 2 and 4. I've tried other examples with "break" and "continue", and it worked. Am I doing something wrong?

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

      @@irynahryma2605
      a=["Python", "Java", "Swift", "C", "C++"]
      for i in a:
      if i.upper()=="SWIFT" or i.upper()=="C++":
      continue
      print(i)

  • @ppirsjsh505
    @ppirsjsh505 3 ปีที่แล้ว +8

    languages=["phyton","java","swift","C","C++"]
    for character in languages:
    if character=="C++" or character=="swift":
    continue
    print(character)

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

    thank you sir I was able to complete your home work.

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

    why can't we just use an if statement instead of a while loop at 3:34?

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

    languages = 'Python', 'Java', 'Swift', 'C', 'C++'
    for language in languages:
    if language == 'Swift':
    continue
    elif language == 'C++':
    continue
    print(language)

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

      #lol, we think almost the same:
      languages=("Python","Java","Swift","C","C++")
      for language in languages:
      if language=="Swift" or language=="C++":
      continue
      print(language)

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

    for i in range(10):
    language = str(input("Enter a language: "))
    if language == "Swift" or language == "c++":
    continue
    print(language)

  • @prajilshrestha7995
    @prajilshrestha7995 4 ปีที่แล้ว +37

    Thumbnail: Feeling cute, might teach python later :D

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

      I don't understand your comment.. how you feel the cute? Teaching Python later to whom?

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

      😂

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

      @@RedBull.RedBull didn't understand the assignment.

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

      🤣🤣🤣 nailed it!

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

    I have written the same code just changed the variable " item" into "digits" at 2:36 but I am getting

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

    languages = [ "Python" , "Java" , "Swift" , "C" , "C++"]
    for a in languages:
    if a == "Swift":
    continue
    if a == "C++":
    continue
    print(a)

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

      Are bhai output nahi aa raha

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

      @@kishansindhi5181 really? What's ur error? I'll see if I can help..

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

      can you do it by input function. plz!

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

      input the language by the user

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

    If I type-
    "if item == 3:
    break"
    after "print(item)" it gives Indentation error. Does anybody know why this happens.

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

      If it says indentation error then you probably messed up somewhere on the indentations

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

    Love your videos..and website...thanks so much for all that you and your team do...

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

    Great tutori, very professional and easy to follow. The only problem I have is ....I do not know where to find this "link below" where I can check the solution to exercizes at the end of each tutorial.

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

      Hi Nick,
      You can find solutions to the exercise tasks in this link: github.com/programiz/python-course/

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

    But bro have a doubt that should i watch your video or study from the website and i think video is best because my brother is learning from the website and it take a lot of times but in video you explain soo nicely and fast

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

    Wait! I'm using your Learn Python app and it is really helpful!

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

    for languages in ['Python','Swift','C++','C','Java']:
    if languages =='Swift' or languages=='C++':
    continue
    print(languages)

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

    Learning Python is something you would like to get in your skills, but you do not know where to start? This NEW channel will help you out leaning Python Programming from scratch - for complete Beginners, Intermediate and Advanced Levels

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

    languages = ["Python", "Java", "Swift", "C", "C++"]
    for language in languages:
    if language == "Swift" or language == "C++":
    continue
    print(language)

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

    THANK YOU SIR
    HERE IS THE CODING TASK
    languages = ["PYTHON","JAVA","SWIFT","C","C++"]
    for i in languages:

    if i == "C++" or i == "SWIFT" :
    continue

    print (i)

  • @Aravindblaze95
    @Aravindblaze95 5 หลายเดือนก่อน +1

    languages = ["Python", "Java", "Swift", "C", "C++"]
    result =[]
    for language in languages:
    if language in ["Swift"]:
    continue
    if language in ["C++"]:
    break
    result.append(language)
    print(f"The Output is {result}")

    • @Aravindblaze95
      @Aravindblaze95 5 หลายเดือนก่อน +1

      The Output is ['Python', 'Java', 'C']

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

    lang = ["python","java","swift","c","c++"]
    for x in lang:
    if (x == "java"):
    continue
    elif (x == "c++"):
    continue
    print(x)

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

    Hi, I am loving the course. But this lesson appears to be out of order when I use the playlist to access the programs, it is appearing before lesson 9, instead of after. I am taking notes and practicing every exercise you demonstrate and then I vary my code a bit to see that I understand what you have taught. Thank you for this great series

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

    I appreciate you man, thanks for these tutorials

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

    Thanks for clearing my confusion, it was really helpful but take care of your head don't move it so much it might "Break" and you may not be able to "Continue" with such series.

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

    where is the github link sir?

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

    why used float number here? if we use int number what will happened

  • @SUMANKUMAR-nt2ur
    @SUMANKUMAR-nt2ur 3 ปีที่แล้ว

    Sir when next video will post

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

    Wow you are such a great mentor , really helping to build basics :) God Bless you :)

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

    thisset = {'python', 'java', 'c', 'swift', 'c++'}
    for x in thisset:
    print(x)
    if x == 'switf' 'c++':
    continue

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

    thank you for this video it was helpful :)

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

    Dude you are an excellent teacher...am now enjoying coding
    languages=['python','java','swift','c','c++']
    for language in languages:
    languages=['python','java','swift','c','c++']
    if language==('swift'):
    continue
    if language==('c++'):
    break
    print(language)

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

    Op sir. With your 1video I can understand easily.
    I think you are a South Indian🇮🇳👳. I hope you will continue posting more videos regarding python. ❤❤

    • @Anonymous-tt7yi
      @Anonymous-tt7yi 3 ปีที่แล้ว

      Yup, I am pretty sure because his first software job was in Hyderabad, India.

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

      he is from nepal bro...

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

    languages=["pyhton","java","c","c++","swift"]
    for tongue in languages:
    if tongue=="swift":
    continue
    elif tongue=="c++":
    continue
    else:
    print(tongue)

  • @EmereEmmanuel
    @EmereEmmanuel 3 หลายเดือนก่อน

    here we go!!!
    languages = ['python', 'java' 'swift', 'php', 'c', 'c++']
    for i in languages:
    if i == 'swift' or i == 'c++':
    continue
    print(i)

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

    Y r we using or during the comparison

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

    for languages in ['Python', 'Java', 'Swift', 'C', 'C++']:
    if (languages == 'Swift' or languages == 'C++'):
    continue
    print("Language is: ", languages)

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

    I am new in programing . After several attempts, I found out the answer on the Github repository is wrong. Correct code should be
    list = ["Python", "Java", "Swift", "C", "C++"]
    for item in list:
    if item == "Swift" or item =="C++"
    continue
    print(item)

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

      Sorry it is right, I realized my mistake

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

      you forgot to put : at the end of the if item == "Swift" or item =="C++":

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

    languages =["Python", "Java", "C", "Swift", "C++"]
    for character in languages:
    if character == "Swift" or character =="C++":
    break
    print(character)
    Or......
    languages =["Python", "Java", "C", "Swift", "C++"]
    for character in languages:
    if character == "Swift" or character =="C++":
    continue
    print(character)

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

      I do not recommend the first solution, it will work in this case because Swift and C++ are the last values in the list, but if one of them was the first item on the list then the loop would break and none of the languages would be printed.

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

      @@pinkshoelace8388 yes i agree. I realised this when I progressed in python. Thanks for spotting :-)

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

    What means float(input())?
    Thanks!

    • @VikasChauhan-ue2th
      @VikasChauhan-ue2th 3 ปีที่แล้ว +3

      Float means decimal numbers like 10.6, 9.0, 4.89, etc.
      If you try "int" instead of "float" it will only give you integer values like 10, 9, 4 and not the decimal values.

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

    languages = ["Python", "Java", "Swift", "C", "C++"]
    for item in languages:
    if item=="Swift" or item=="C++":
    continue
    print(item)
    Programming is also about optimizing the code. I see a lot of people in the comment just making the program complex unnecessarily.

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

    languages = ["Python", "Java", "Swift", "C", "C++"]
    for item in languages:
    if item == "Swift" or item == "C++":
    continue
    else:
    print(item)

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

      The logic you are trying to use is correct> However, there is an error in the test condition. Change the test condition to:
      item == "Swift" or item == "C++"

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

      @@programizstudios Thanks

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

      @@programizstudios but isn't it the same thing sir?

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

    Nice Tutorial

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

    nice explanation

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

    #Can you create a program so that all items of the language are printed except swift and C++
    # language=["Python","Java","Swift", "c","c++"]
    language=["Python","Java","Swift","C","C++"]
    for i in language:
    if i=="Swift":
    continue
    elif i=="C++":
    continue
    else:
    print(i)

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

    lang = ["Python", "Java", "Swift", "C", "C++"]
    for item in lang:
    if item == "Swift" or item == "C++":
    continue
    print(item)

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

    languages=["python","java","swift","c","c++"]
    for i in languages:
    if i=="swift":
    continue
    if i=="c++":
    continue
    print(i)
    print("h")

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

    languages = [ “python” , “Java” , “swift” , “C” , “C++” ]
    for i in languages:
    if i == “C++”:
    continue
    elif i == “swift”:
    continue
    print(i)

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

    languages = ['python', 'java', 'swift', 'C', 'C++']
    for item in languages:
    if item == 'swift' or item == 'C++':
    continue
    print(item)
    -- Programming Task Answer --

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

    language = ["Python", "Java", "Swift", "C", "C++"]
    for item in language:
    if item=="Swift" or item=="C++":
    continue
    print(item)

  • @NehaGupta-if7se
    @NehaGupta-if7se 3 ปีที่แล้ว

    Thank u so much sir...

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

    languages = ["Python", "Java", "Swift", "C", "C++"]
    for i in languages:
    if i == "Swift" or i == "C++":
    continue
    print(i)

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

    languages=["python","java","c","c++","swift"]
    exclude=["java","c"]
    for i in languages:
    if i in exclude:
    continue
    else:
    print(i)

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

    Thank you!

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

    languages = [ " python" , " java" , " swift", " c" , " c++"]
    for language in langyages :
    print ( language)
    if language =" swift" or language = " c++"
    break

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

    I forgot about OR, so my code is:
    languages = [ ]
    for language in languages:
    if language == 'swift':
    continue
    if language =='C++':
    break
    print(language)

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

    lang = ['python','java','swift','c','c++']
    for i in lang:
    if (i==lang[2]) or (i==lang[4]) :
    continue
    else:
    print(i)

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

    languages = ["Python", "Java", "Swift", "C", "C++"]

    for langauge in languages:
    if language == "Swift" or language == "C++":
    continue
    print(langauge)
    output :- Traceback (most recent call last):

    NameError: name 'language' is not defined

  • @relaxingmoments-787
    @relaxingmoments-787 2 ปีที่แล้ว

    I can't understand this one but how about this :- languages = ["python", "java"', " Swift", "C"', " C++"]
    Print(languages [0])
    Print(languages [1])
    Print(languages [3])

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

    languages = ["Python", "Java", "Swift", "C", "C++"]
    list=[]
    for _ in range(len(languages)):
    if languages[_] == "Python" or languages[_] == "Java" or languages[_] == "C":
    list.append(languages[_])
    print(list)

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

    thank u!

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

    where the fuck did the for and in range come from there is no tutorial for that in this series

  • @f.a5148
    @f.a5148 11 หลายเดือนก่อน

    my like turned your video from 1.4k to 1.5k

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

    #Question_answer
    language = ["Python", "Java", "Swift", "C", "C++"]
    for p_language in language:
    if p_language == "Swift":
    continue
    if p_language == "C++":
    continue
    print(p_language)

  • @bhavishibansal2573
    @bhavishibansal2573 4 ปีที่แล้ว +6

    lang=["Python","Java","Swift","C","C++"]
    lang.remove("Swift")
    lang.remove("C++")
    print(lang)

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

      you should use loop and what is thought in this vid

  • @debebebelaye1881
    @debebebelaye1881 7 หลายเดือนก่อน

    my_list = ["python", "Java", "Swift", "C", "C++"]
    for i in my_list:
    if i == "Swift" or i == "C++":
    continue
    print(i, end=",")

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

    languages = ["Python", "Java", "Swift", "C", "C++"]
    print(languages[0])
    print(languages [1])
    print (languages [3])

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

    languages=["python","java","swift","c","c++"]
    print(languages[0,1,3])

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

    Is this acceptable?
    lang = ["Python", "Java", "Swift", "C", "C++"]
    for i in lang:
    if i == lang[2]:
    continue
    if i == lang[4]:
    continue
    print(i)

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

    [print(i) for i in ["python", "java", "swift", "c++", "c"] if i!="swift" and i!="c++"]

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

    languages = ["Python", "Java", "Swift", "C", "C++"]
    without break&continue:
    for i in languages:
    if i != "Swift" and i !="C++":
    print(i)
    with break&continue:
    for i in languages:
    if i == "Swift":
    continue
    if i == "C++":
    continue
    print(i)

  • @SahilShaikh-7
    @SahilShaikh-7 ปีที่แล้ว

    language = ['python','java','swift','c','c++']
    new_language = [ ]
    for i in language:
    if i == "swift" or i == 'c++':
    continue
    else:
    new_language.append(i)
    new_language will be ['python', 'java', 'c']

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

    No thank you! ❤

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

    you didn't turn your head enough

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

    😇

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

    Thalakai oopadam aaparaa babu

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

    Binod

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

    Why Break and continue are giving no output? Just blank, not any warning,
    Write exactly same but no output, only the end has printed

  • @nikanayo
    @nikanayo 2 ปีที่แล้ว +7

    for languages in ['Python', 'Java', 'Swift', 'C', 'C++']:
    if (languages == 'Swift'or languages == 'C++'):
    continue
    print(languages)

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

    languages = ["Python","Java","Swift","C","C++"]
    for i in languages:
    if i == languages[2] or i == languages[4]:
    continue
    else:
    print(i)

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

    languages = ["Python", "Java", "Swift", "C", "C++"]
    for language in languages:
    if language == "Swift" or language == "C++":
    continue
    print(language)

  • @didio.1791
    @didio.1791 2 ปีที่แล้ว

    languages = ['python','java','swift','c','c++']
    for language in languages:
    if language == 'swift' or language == 'c++':
    continue
    print(language)

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

    languages = ['Python', 'Java', 'C', 'Swift', 'C++']
    for i in languages:
    if i == 'C++' or i == 'Swift':
    continue
    else:
    print(i)

  • @lakshanj.kumara7648
    @lakshanj.kumara7648 ปีที่แล้ว

    languages=("Python" , "java" , "Swift" ,"C","C++")
    for language in languages:
    if language=="Swift" or language=="C":
    continue
    print(language)

  • @Avinashsingh-lz3ey
    @Avinashsingh-lz3ey 3 ปีที่แล้ว

    languages = ["Python", "Java", "Swift", "C", "C++"]
    for language in languages:
    if language == "Swift" or language == "C++":
    continue
    print(language)

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

      but u just ripped-off that other comment tho

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

    languages = ["Python", "Java", "Swift", "C", "C++"]
    for i in languages:
    if i=='Swift' or i=='C++':
    continue
    print(i)

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

    languages = 'Python', 'Java', 'Swift', 'C', 'C++'
    for language in languages:
    if language == 'Swift' or language== 'C++':
    continue
    print(language)

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

    languages = ["Python","Java","swift","C","C++"]
    for i in languages:
    if i=="swift" or i=="C++":
    continue
    print(i)

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

    languages = ["Python", "Java", "Swift", "C", "C++"]
    for language in languages:
    if language == "Swift" and "C++":
    continue
    print(language)

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

    languages=["c++","c","phyton","swift","rust"]
    for language in languages:
    if language == "swift" or language == "c++":
    continue
    print(language)