41 lines
1 KiB
Python
41 lines
1 KiB
Python
#!/usr/bin/python3
|
|
|
|
# Defining and printing list lengths.
|
|
|
|
# Lists of text values
|
|
dogNames = [ "harry", "Shenanigans","katrina","Tanner","Yukon Jack", "Colorado","Mandy"]
|
|
firstNames = ["edward","david", "Bob","mary","alice"]
|
|
txtList = ["7", "2", "12", "18", "16", "21"]
|
|
|
|
# Lists of nubers. These could be integers or floats.
|
|
intList = [7, 2, 12, 18, 16, 21]
|
|
primeList = [1, 2, 3, 7, 11, 13, 17, 19]
|
|
|
|
# Print the entire list
|
|
print("Print the entire list.")
|
|
print (dogNames)
|
|
print(firstNames)
|
|
print(txtList)
|
|
print(intList)
|
|
print(primeList)
|
|
print("\n")
|
|
|
|
|
|
# Print the length of the list
|
|
print("Print the length of the lists.")
|
|
print( len(dogNames) )
|
|
print(len(firstNames) )
|
|
print(len(txtList) )
|
|
print(len(intList) )
|
|
print(len(primeList) )
|
|
print("\n")
|
|
|
|
|
|
# Print the list and the length
|
|
print("Print the length of the lists.")
|
|
print (dogNames," length = ",len(dogNames))
|
|
print(firstNames," length = ",len(firstNames))
|
|
print(txtList," length = ",len(txtList))
|
|
print(intList," length = ",len(intList))
|
|
print(primeList," length = ",len(primeList))
|
|
|