Is there a difference in break statement between C and Python?What is the difference between #include <filename> and #include “filename”?Replacements for switch statement in Python?Calling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?What is the difference between Python's list methods append and extend?Does Python have a ternary conditional operator?Difference between __str__ and __repr__?Improve INSERT-per-second performance of SQLite?Does Python have a string 'contains' substring method?

Is "cool" appropriate or offensive to use in IMs?

What is the object moving across the ceiling in this stock footage?

Imitating a conveyor belt in `TikZ`

Python program to take in two strings and print the larger string

Why does Mjolnir fall down in Age of Ultron but not in Endgame?

Why does this if-statement combining assignment and an equality check return true?

What are these arcade games in Ghostbusters 1984?

Why did the person in charge of a principality not just declare themself king?

Using credit/debit card details vs swiping a card in a payment (credit card) terminal

What to keep in mind when telling an aunt how wrong her actions are, without creating further family conflict?

Why were helmets and other body armour not commonplace in the 1800s?

Is it rude to call a professor by their last name with no prefix in a non-academic setting?

Is it true that cut time means "play twice as fast as written"?

Could a 19.25mm revolver actually exist?

Did 20% of US soldiers in Vietnam use heroin, 95% of whom quit afterwards?

Should one buy new hardware after a system compromise?

Who will lead the country until there is a new Tory leader?

In general, would I need to season a meat when making a sauce?

Is it legal to meet with potential future employers in the UK, whilst visiting from the USA

What was the idiom for something that we take without a doubt?

Looking for a soft substance that doesn't dissolve underwater

Can my floppy disk still work without a shutter spring?

Grammar Question Regarding "Are the" or "Is the" When Referring to Something that May or May not be Plural

Should I disclose a colleague's illness (that I should not know) when others badmouth him



Is there a difference in break statement between C and Python?


What is the difference between #include <filename> and #include “filename”?Replacements for switch statement in Python?Calling an external command in PythonWhat are metaclasses in Python?What is the difference between @staticmethod and @classmethod?What is the difference between Python's list methods append and extend?Does Python have a ternary conditional operator?Difference between __str__ and __repr__?Improve INSERT-per-second performance of SQLite?Does Python have a string 'contains' substring method?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








1















I'm working on a python program and i'm still a beginner in python.
i've a c program that i'm trying to write in python, i'm facing a problem because in this program, break statement isn't performing the same way.
I've a loop and then a second inner loop and if condition where i need to break if the if condition is valid.
What i need is one break statement in the if condition.
in Python using this only break statement isn't giving me correct results while in c it's working.
I noticed that in C if i put a second break in the second loop after the if condition i'm getting same wrong results i'm getting in python.



for f in range(1,6):
for k in range(1,8):
if(x==y):
break
if ///// :
break


for (int f = 1; f < 6; f++)
for (int k = 1; k < 8; k++)
if(x==y)
break;

if /////
break



so these two codes aren't giving same result,
while if i change c code to this one, it will give me same pythong wrong results



for (int f = 1; f < 6; f++)
for (int k = 1; k < 8; k++)
if(x==y)
break;

break; <------------------------------- if i add this
if //////
break;










share|improve this question

















  • 2





    I don't see a reason why those two code snippets would behave differently, unless your python program had an indentation issue where the interpreter thought your break statement was in the outer loop, not the inner one. I suggest you add some print statements to both pieces of code to verify the result you're getting. Also, you weren't very specific in your question about what result you saw that was different from what you were expecting. Please edit your question to fix that.

    – Niayesh Isky
    Mar 24 at 3:47






  • 1





    Also, are x and y supposed to be f and k? If not, where are they coming from? Are they being changed inside the loops?

    – Niayesh Isky
    Mar 24 at 3:48











  • no x and y aren't f and k, and actually it's a big program and i have results i'm waiting for, it's a cryptanalysis system that i'm trying to write in python.

    – kotasha
    Mar 24 at 3:52











  • You should always produce an example that is consistent: stackoverflow.com/help/mcve

    – Klaus D.
    Mar 24 at 4:19

















1















I'm working on a python program and i'm still a beginner in python.
i've a c program that i'm trying to write in python, i'm facing a problem because in this program, break statement isn't performing the same way.
I've a loop and then a second inner loop and if condition where i need to break if the if condition is valid.
What i need is one break statement in the if condition.
in Python using this only break statement isn't giving me correct results while in c it's working.
I noticed that in C if i put a second break in the second loop after the if condition i'm getting same wrong results i'm getting in python.



for f in range(1,6):
for k in range(1,8):
if(x==y):
break
if ///// :
break


for (int f = 1; f < 6; f++)
for (int k = 1; k < 8; k++)
if(x==y)
break;

if /////
break



so these two codes aren't giving same result,
while if i change c code to this one, it will give me same pythong wrong results



for (int f = 1; f < 6; f++)
for (int k = 1; k < 8; k++)
if(x==y)
break;

break; <------------------------------- if i add this
if //////
break;










share|improve this question

















  • 2





    I don't see a reason why those two code snippets would behave differently, unless your python program had an indentation issue where the interpreter thought your break statement was in the outer loop, not the inner one. I suggest you add some print statements to both pieces of code to verify the result you're getting. Also, you weren't very specific in your question about what result you saw that was different from what you were expecting. Please edit your question to fix that.

    – Niayesh Isky
    Mar 24 at 3:47






  • 1





    Also, are x and y supposed to be f and k? If not, where are they coming from? Are they being changed inside the loops?

    – Niayesh Isky
    Mar 24 at 3:48











  • no x and y aren't f and k, and actually it's a big program and i have results i'm waiting for, it's a cryptanalysis system that i'm trying to write in python.

    – kotasha
    Mar 24 at 3:52











  • You should always produce an example that is consistent: stackoverflow.com/help/mcve

    – Klaus D.
    Mar 24 at 4:19













1












1








1








I'm working on a python program and i'm still a beginner in python.
i've a c program that i'm trying to write in python, i'm facing a problem because in this program, break statement isn't performing the same way.
I've a loop and then a second inner loop and if condition where i need to break if the if condition is valid.
What i need is one break statement in the if condition.
in Python using this only break statement isn't giving me correct results while in c it's working.
I noticed that in C if i put a second break in the second loop after the if condition i'm getting same wrong results i'm getting in python.



for f in range(1,6):
for k in range(1,8):
if(x==y):
break
if ///// :
break


for (int f = 1; f < 6; f++)
for (int k = 1; k < 8; k++)
if(x==y)
break;

if /////
break



so these two codes aren't giving same result,
while if i change c code to this one, it will give me same pythong wrong results



for (int f = 1; f < 6; f++)
for (int k = 1; k < 8; k++)
if(x==y)
break;

break; <------------------------------- if i add this
if //////
break;










share|improve this question














I'm working on a python program and i'm still a beginner in python.
i've a c program that i'm trying to write in python, i'm facing a problem because in this program, break statement isn't performing the same way.
I've a loop and then a second inner loop and if condition where i need to break if the if condition is valid.
What i need is one break statement in the if condition.
in Python using this only break statement isn't giving me correct results while in c it's working.
I noticed that in C if i put a second break in the second loop after the if condition i'm getting same wrong results i'm getting in python.



for f in range(1,6):
for k in range(1,8):
if(x==y):
break
if ///// :
break


for (int f = 1; f < 6; f++)
for (int k = 1; k < 8; k++)
if(x==y)
break;

if /////
break



so these two codes aren't giving same result,
while if i change c code to this one, it will give me same pythong wrong results



for (int f = 1; f < 6; f++)
for (int k = 1; k < 8; k++)
if(x==y)
break;

break; <------------------------------- if i add this
if //////
break;







python c loops break






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Mar 24 at 3:43









kotashakotasha

204




204







  • 2





    I don't see a reason why those two code snippets would behave differently, unless your python program had an indentation issue where the interpreter thought your break statement was in the outer loop, not the inner one. I suggest you add some print statements to both pieces of code to verify the result you're getting. Also, you weren't very specific in your question about what result you saw that was different from what you were expecting. Please edit your question to fix that.

    – Niayesh Isky
    Mar 24 at 3:47






  • 1





    Also, are x and y supposed to be f and k? If not, where are they coming from? Are they being changed inside the loops?

    – Niayesh Isky
    Mar 24 at 3:48











  • no x and y aren't f and k, and actually it's a big program and i have results i'm waiting for, it's a cryptanalysis system that i'm trying to write in python.

    – kotasha
    Mar 24 at 3:52











  • You should always produce an example that is consistent: stackoverflow.com/help/mcve

    – Klaus D.
    Mar 24 at 4:19












  • 2





    I don't see a reason why those two code snippets would behave differently, unless your python program had an indentation issue where the interpreter thought your break statement was in the outer loop, not the inner one. I suggest you add some print statements to both pieces of code to verify the result you're getting. Also, you weren't very specific in your question about what result you saw that was different from what you were expecting. Please edit your question to fix that.

    – Niayesh Isky
    Mar 24 at 3:47






  • 1





    Also, are x and y supposed to be f and k? If not, where are they coming from? Are they being changed inside the loops?

    – Niayesh Isky
    Mar 24 at 3:48











  • no x and y aren't f and k, and actually it's a big program and i have results i'm waiting for, it's a cryptanalysis system that i'm trying to write in python.

    – kotasha
    Mar 24 at 3:52











  • You should always produce an example that is consistent: stackoverflow.com/help/mcve

    – Klaus D.
    Mar 24 at 4:19







2




2





I don't see a reason why those two code snippets would behave differently, unless your python program had an indentation issue where the interpreter thought your break statement was in the outer loop, not the inner one. I suggest you add some print statements to both pieces of code to verify the result you're getting. Also, you weren't very specific in your question about what result you saw that was different from what you were expecting. Please edit your question to fix that.

– Niayesh Isky
Mar 24 at 3:47





I don't see a reason why those two code snippets would behave differently, unless your python program had an indentation issue where the interpreter thought your break statement was in the outer loop, not the inner one. I suggest you add some print statements to both pieces of code to verify the result you're getting. Also, you weren't very specific in your question about what result you saw that was different from what you were expecting. Please edit your question to fix that.

– Niayesh Isky
Mar 24 at 3:47




1




1





Also, are x and y supposed to be f and k? If not, where are they coming from? Are they being changed inside the loops?

– Niayesh Isky
Mar 24 at 3:48





Also, are x and y supposed to be f and k? If not, where are they coming from? Are they being changed inside the loops?

– Niayesh Isky
Mar 24 at 3:48













no x and y aren't f and k, and actually it's a big program and i have results i'm waiting for, it's a cryptanalysis system that i'm trying to write in python.

– kotasha
Mar 24 at 3:52





no x and y aren't f and k, and actually it's a big program and i have results i'm waiting for, it's a cryptanalysis system that i'm trying to write in python.

– kotasha
Mar 24 at 3:52













You should always produce an example that is consistent: stackoverflow.com/help/mcve

– Klaus D.
Mar 24 at 4:19





You should always produce an example that is consistent: stackoverflow.com/help/mcve

– Klaus D.
Mar 24 at 4:19












1 Answer
1






active

oldest

votes


















4














break behaves the same in both languages. Check the indentation in your Python program. Your first two samples shpuld behave the same.






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320540%2fis-there-a-difference-in-break-statement-between-c-and-python%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    break behaves the same in both languages. Check the indentation in your Python program. Your first two samples shpuld behave the same.






    share|improve this answer



























      4














      break behaves the same in both languages. Check the indentation in your Python program. Your first two samples shpuld behave the same.






      share|improve this answer

























        4












        4








        4







        break behaves the same in both languages. Check the indentation in your Python program. Your first two samples shpuld behave the same.






        share|improve this answer













        break behaves the same in both languages. Check the indentation in your Python program. Your first two samples shpuld behave the same.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 24 at 3:49









        CoffeeTableEspressoCoffeeTableEspresso

        905418




        905418





























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55320540%2fis-there-a-difference-in-break-statement-between-c-and-python%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

            155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해