python for if code example
Example 1: for-else in python
numbers = [2, 4, 6, 8, 1]
for number in numbers:
if number % 2 == 1:
print(number)
break
else:
print("No odd numbers")
Example 2: if statements python
water = input('Does your creature live underwater?')
if water == 'yes':
print('Your creature lives underwater')
else:
print('Your creature does not live underwater')
Example 3: if loop in python syntax
if a>b :
print(a)