homework5git/if/if04.py

24 lines
544 B
Python

#!/usr/bin/python3
# Program: if02
# Lists of numbers. These could be integers or floats.
intList = [7, 2, 16, 18, 12, 21]
# Print the list and the length
print(intList," length = ",len(intList))
print(f"Print each value in the list")
counter = 0
for item in intList:
print(f"intList[{counter}] = {item:2d}")
counter += 1
cutoff = 13
print(f"Print each value in the list >= {cutoff}")
counter = 0
for item in intList:
if(item >= cutoff):
print(f"intList[{counter}] = {item:2d}")
counter += 1