user250189
0
Q:

python while continue

## When the program execution reaches a continue statement, 
## the program execution immediately jumps back to the start 
## of the loop.
while True:
    print('Who are you?')
    name = input()
    if name != 'Joe':
        continue
    print('Hello, Joe. What is the password? (It is a fish.)')
    password = input()
    if password == 'swordfish':
        break
print('Access granted.')
4
nums = [6,8,0,5,3]
product = 1

for num in nums:
  if num == 0:
    product = 0
    break # stops the for loop
  product *= num

print(product)
5
while input("Do You Want To Continue? [y/n]") == "y":
    # do something
    print("doing something")
0
while True:
    # some code here
    if input('Do You Want To Continue? ') != 'y':
        break
0
#!/usr/bin/python

for num in range(10,20):  #to iterate between 10 to 20
   for i in range(2,num): #to iterate on the factors of the number
      if num%i == 0:      #to determine the first factor
         j=num/i #to calculate the second factor
         print '%d equals %d * %d' % (num,i,j)
         break #to move to the next number, the #first FOR
   else:        # else part of the loop
      print num, 'is a prime number'
-1

New to Communities?

Join the community