#for_loop_example_1.py

import random
import sys
import os

##The for loop will repeat a loop based on the contents
##of a list or similar item that contains a list-like structure,
##such as dictionaries and files.

my_list = [ 1, 17, "House", 28 ]

print("\nThe values below are read from a list with a \"for\" loop")
for val in my_list:
    print(val)

my_dictionary = {}
my_dictionary["first"] = "Harry"
my_dictionary["last"] = "Baya"

#note: When used with dictionaries the sequence of items
#      found by a for loop is unpredictable

print("\nThe values below are read from a dictionary with a \"for\" loop")
for val in my_dictionary:  # the for loop will get the "key" for each dictionary entry
                           # to learn about dictionaries, see dictionary_example_1.py
    print(val,my_dictionary[val])

# Python ranges are useful with for loops

print("\nThe values below are taken from a \"range\" and printed with a\"for\" loop.")
for val in range(8,24):
    print(val)

# for an example of using a for loop with a file, see the File read example (file_read_example_1

