<jupyter_start><jupyter_text>5. More lists  Looping through an entire list<jupyter_code>color_names = ['tan', 'dark olive green', 'coral', 'blue', 'crimson']
for color_name in color_names:
    print(f"Hey, let's paint the house {color_name}!")<jupyter_output>Hey, let's paint the house tan!
Hey, let's paint the house dark olive green!
Hey, let's paint the house coral!
Hey, let's paint the house blue!
Hey, let's paint the house crimson!<jupyter_text>Doing more work within a `for` loop<jupyter_code>for color_name in color_names:
    print(f"Hey, let's paint the house {color_name}!")
    name_length = len(color_name)
    print(f"  (Did you know that {color_name} is {name_length} characters long?)")<jupyter_output>Hey, let's paint the house tan!
  (Did you know that tan is 3 characters long?)
Hey, let's paint the house dark olive green!
  (Did you know that dark olive green is 16 characters long?)
Hey, let's paint the house coral!
  (Did you know that coral is 5 characters long?)
Hey, let's paint the house blue!
  (Did you know that blue is 4 characters long?)
Hey, let's paint the house crimson!
  (Did you know that crimson is 7 characters long?)<jupyter_text>Doing something after a `for` loop<jupyter_code>for color_name in color_names:
    print(f"Hey, let's paint the house {color_name}!")
    name_length = len(color_name)
    print(f"  (Did you know that {color_name} is {name_length} characters long?)")
print('That was an interesting exercise.')<jupyter_output>Hey, let's paint the house tan!
  (Did you know that tan is 3 characters long?)
Hey, let's paint the house dark olive green!
  (Did you know that dark olive green is 16 characters long?)
Hey, let's paint the house coral!
  (Did you know that coral is 5 characters long?)
Hey, let's paint the house blue!
  (Did you know that blue is 4 characters long?)
Hey, let's paint the house crimson!
  (Did you know that crimson is 7 characters long?)
That was an interesting exercise.<jupyter_text>Using the `range()` function<jupyter_code>for number in range(1, 10):
    print(number)<jupyter_output>1
2
3
4
5
6
7
8
9<jupyter_text>Using `range()` to make a list of numbers<jupyter_code>print(range(1, 10))
numbers = list(range(1, 10))
print(numbers)
odd_numbers = list(range(1, 10, 2))
print(odd_numbers)
tip_amounts = []
for value in range(1, 11):
    tip_amount = value * 0.2
    tip_amounts.append(tip_amount)
print(tip_amounts)<jupyter_output>[0.2, 0.4, 0.6000000000000001, 0.8, 1.0, 1.2000000000000002, 1.4000000000000001, 1.6, 1.8, 2.0]<jupyter_text>Simple statistics with a list of numbers<jupyter_code>the_numbers = [4, 8, 15, 16, 23, 42]
print(f"The smallest of the numbers is: {min(the_numbers)}.")
print(f"The largest value of the numbers is: {max(the_numbers)}.")
print(f"The sum of the numbers is {sum(the_numbers)}.")
tip_amounts = [value * 0.2 for value in range(1, 11)]
print(tip_amounts)<jupyter_output>[0.2, 0.4, 0.6000000000000001, 0.8, 1.0, 1.2000000000000002, 1.4000000000000001, 1.6, 1.8, 2.0]<jupyter_text>Slicing a list<jupyter_code>languages = ['ARM assembly', 'Basic', 'C', 'Dart', 'Erlang', 'F#', 'Go', 'Haskell']
first_three_languages = languages[0:3]
print(first_three_languages)
print(languages[3:5])
print(languages[:3])
print(languages[9:12])
print(languages[-4:])<jupyter_output>['Erlang', 'F#', 'Go', 'Haskell']<jupyter_text>Looping through a slice<jupyter_code>for language in languages[2:6]:
    print(f"I want to learn how to program in {language}.")<jupyter_output>I want to learn how to program in C.
I want to learn how to program in Dart.
I want to learn how to program in Erlang.
I want to learn how to program in F#.<jupyter_text>Copying a listLet's create a list, `my_flavor_list`, then create another list, `my_other_flavor_list`, based on `my_flavor_list`<jupyter_code>my_flavor_list = ['chocolate', 'vanilla', 'strawberry']
my_other_flavor_list = my_flavor_list

print(f"my_flavor_list: {my_flavor_list}")
print(f"my_other_flavor_list: {my_other_flavor_list}")<jupyter_output>my_flavor_list: ['chocolate', 'vanilla', 'strawberry']
my_other_flavor_list: ['chocolate', 'vanilla', 'strawberry']<jupyter_text>Let's make a change to `my_flavor_list` and see what happens.<jupyter_code>my_flavor_list.append('butter pecan')

print(f"my_flavor_list: {my_flavor_list}")
print(f"my_other_flavor_list: {my_other_flavor_list}")<jupyter_output>my_flavor_list: ['chocolate', 'vanilla', 'strawberry', 'butter pecan']
my_other_flavor_list: ['chocolate', 'vanilla', 'strawberry', 'butter pecan']<jupyter_text>Adding butter pecan to `my_flavor_list` also added it to `my_other_flavor_list`! What gives? TODO: Add explanation here<jupyter_code>separate_flavor_list = my_flavor_list[:]
separate_flavor_list.append('birthday cake')

print(f"my_flavor_list: {my_flavor_list}")
print(f"separate_flavor_list: {separate_flavor_list}")<jupyter_output>my_flavor_list: ['chocolate', 'vanilla', 'strawberry', 'butter pecan']
separate_flavor_list: ['chocolate', 'vanilla', 'strawberry', 'butter pecan', 'birthday cake']<jupyter_text>Tuples  Defining a tuple<jupyter_code>letter_paper_dimensions = (8.5, 11)

print(f"The width of letter-size paper is {letter_paper_dimensions[0]} inches.")
print(f"The height of letter-size paper is {letter_paper_dimensions[1]} inches.")<jupyter_output>The width of letter-size paper is 8.5 inches.
The height of letter-size paper is 11 inches.<jupyter_text>Looping through all the values in a tuple<jupyter_code>for dimension in letter_paper_dimensions:
    print(dimension)<jupyter_output>8.5
11<jupyter_text>Changing the value of a tupleYou can't change any individual value within a tuple...<jupyter_code># Uncomment the line below and try running it.
# letter_paper_dimensions[0] = 9<jupyter_output><empty_output><jupyter_text>...but you *can* reassign a different tuple to the same variable:<jupyter_code>letter_paper_dimensions = (9, 11)<jupyter_output><empty_output><jupyter_text>Beyond the book  Copying lists with the `copy()` method<jupyter_code>another_separate_flavor_list = my_flavor_list.copy()
another_separate_flavor_list.append('lemon sherbet')

print(f"my_flavor_list: {my_flavor_list}")
print(f"another_separate_flavor_list: {another_separate_flavor_list}")<jupyter_output>my_flavor_list: ['chocolate', 'vanilla', 'strawberry', 'butter pecan']
another_separate_flavor_list: ['chocolate', 'vanilla', 'strawberry', 'butter pecan', 'lemon sherbet']
{'fraction_non_alphanumeric': 0.1205196431366411, 'fraction_numerical': 0.03365158866802317, 'mean_word_length': 6.888888888888889, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 6, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '16', 'dir': 'jupyter-structured-clean-dedup', 'id': '76378', 'license': 'MIT', 'n_tokens_mistral': 2483, 'n_tokens_neox': 2292, 'n_words': 652, 'path': '5. More lists.ipynb', 'repo_name': 'AccordionGuy/Intro-to-Python-2020', 'size': '6389'}