X
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.
Learn more...
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.
Steps
Community Q&A
-
QuestionHow do you do a nested loop?Adam BlalockCommunity AnswerHere 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.)
-
QuestionWhat about web development?Community AnswerYou need to learn about Django, the Python framework for web development.
-
QuestionHow do you use a while loop to repeat a calculator program?Community AnswerFirst 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
Advertisement