Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8163281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T18:59:00+00:00 2026-06-06T18:59:00+00:00

Possible Duplicate: Why avoid while loops? I am trying to learn Python by following

  • 0

Possible Duplicate:
Why avoid while loops?

I am trying to learn Python by following Learn Python The Hard Way and as I have progressed along I found it mentioned on the site that,

Use a while-loop only to loop forever, and that means probably never. This only applies to Python, other languages are different.

Now I am basically a Java developer and this got me wondering as to why while should be avoided in python although it is widely used in Java. I haven’t been able to find any answer on the internet.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T18:59:01+00:00Added an answer on June 6, 2026 at 6:59 pm

    That statement is highly subjective and I am not sure I’d agree with it. It is easy to have an infinite loop using while in Python:

      while True:
           # do stuff
    

    Perhaps the author was comparing this with C where it is also easy to have an infinite loop with for:

      for(;;)
          /* do stuff */
    

    No such corresponding construct really exists for Python.

    Having said there there are plenty of instances where an infinite loop is useful (in any language) – think event loops, or where the loop control can be simplified by having an infinite loop and only certain conditions causing a break.

    Frequently you’ll be processing sequences such as list and strings and the use of a for-loop will be a natural fit, but I’d not dismiss the while-loop simply because of that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: What does jQuery.fn mean? I have some script on a page trying
Possible Duplicate: UISlider and UIScrollView using iOS SDK 4.3. I've found when I have
Possible Duplicate: How to avoid entering library's source files while debugging in Qt Creator
Possible Duplicate: Read/Write Python Closures In the following function, the internal function does not
Possible Duplicate: Can main function call itself in C++? I found this problem very
Possible Duplicate: Objective C for Windows iPhone development on Windows Is there any way
Possible Duplicate: Python : how to append new elements in a list of list?
Possible Duplicate: Avoid resending forms on php pages Index.html <form method=post action=demo.php> <input type=text
Possible Duplicate: Why avoid increment (“++”) and decrement (“--”) operators in JavaScript? I've heard
Possible Duplicate: How to avoid “!= null” statements in Java? Share your thoughts..

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.