Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

closed While loops with integers in python

+3 votes
asked Sep 21, 2022 by Ben Roberts (220 points)
closed Sep 27, 2022 by Ben Roberts
I’m making a game and I need to use a while loop
closed with the note: It was answered

2 Answers

0 votes
answered Sep 24, 2022 by Pradeep Pant (180 points)
syntax for while loop is


          body of loop


first statement after while loop

Example : you want to print hello 10 times and end one times using while loop

i=1;                #initialization

while( i<=10):      #condition

      print("Hello")       #body of loop

      i=i+1                # next iteration

print("end")            //outside the while loop
0 votes
answered Sep 24, 2022 by Peter Minarik (82,640 points)

Have a look at this.

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.