-1

Here is a simple progarm to tell whether a year is leap or not.

year = input("Enter a year: ")

if year % 4 != 0:
    print"\nNot leap year!"

else:
    if year % 100 != 0:
        print"\nLeap year"
    else:
        if year % 400 == 0:
           print"\nLeap year"
         else:
             print"\nNot leap year"

I want to prompt user "Do you want to continue..(y/n)" then he will enter choice and loop will iterate again but not able to do that. Any suggestions?

DeepSpace
  • 78,697
  • 11
  • 109
  • 154
daya
  • 160
  • 2
  • 14

1 Answers1

1

This is a common way to emulate do-while:

while True:
    # body
    if condition:
       break
deets
  • 6,285
  • 29
  • 28