Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

“Else” condition inside a “for” loop

numbers = [2, 4, 6, 8, 1]

for number in numbers:
    if number % 2 == 1:
        print(number)
        break
else:
    print("No odd numbers")
 
PREVIOUS NEXT
Tagged: #condition #loop
ADD COMMENT
Topic
Name
4+7 =