Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

do while loop 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: #loop #python
ADD COMMENT
Topic
Name
5+5 =