In Python, and many other programming languages, you will need to loop commands several times, or until a condition is fulfilled. It is easy, and the loop itself only needs a few lines of code.

Community Q&A

  • Question
    How do you do a nested loop?
    Adam Blalock
    Adam Blalock
    Community Answer
    Here is a loop within a loop in Python: x = [0,1,2,3,4], y= [10,11,12,13]. For i in x: For ii in y: print i + ii. (Make sure to do it as a single tab before the second "For" and two tabs for the "print" statement.)
  • Question
    What about web development?
    Community Answer
    Community Answer
    You need to learn about Django, the Python framework for web development.
  • Question
    How do you use a while loop to repeat a calculator program?
    Community Answer
    Community Answer
    First create a function. For example, if you wanted to square numbers 1 through 100 and print the results to the screen, I would write: def square(x): return x*x for i in range(1, 101): # stop = 101 because the stop value is not included. This will go from 1-100. print(square(i)).
Advertisement

About This Article

wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 17 people, some anonymous, worked to edit and improve it over time. This article has been viewed 64,575 times.
How helpful is this?
Co-authors: 17
Updated: February 7, 2023
Views: 64,575
Categories: Python
Advertisement