Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

how to make a do while in python

# do while sample loop in python
# do statements in try while number is < 0
i = 0
number = -1
while number < 0:
    try:
        number = int(input("Enter a number: "))
        print(number)
        i += 1
    except ValueError:
        print("Invalid input")
Source by www.codecademy.com #
 
PREVIOUS NEXT
Tagged: #python
ADD COMMENT
Topic
Name
9+9 =