<jupyter_start><jupyter_text>Contents---- [Hello, World!](helloworld)- [Variables](variables)- [Common Errors](errors)- [Strings](strings)- [White Space](whitespace)- [Numbers](numbers)- [User Input](userinput)- [Comments](comments)- [Introduction to Lists](introtolists)- [Editing Lists](editing)- [Looping Through Lists](looping)- [Common List Operations](operations) Hello, World!---When programmers are learning a new language, we tend to write a one line program that prints some version of the message "Hello world!" This is a simple program that shows whether your computer is properly set up to run Python programs.<jupyter_code>print('Hello world!')<jupyter_output>Hello world!<jupyter_text>Click into the above print box and then press the play button at the top. If it works, congratulations! You just ran your first Python program.  Exercise - I love programming:Write a program below that prints out "I love programming!"<jupyter_code>#insert I love programming copde here
print('I love programming')<jupyter_output>I love programming<jupyter_text>Variables---A variable holds a value. You can store the sentence "Hello Python world!" in the variable called "message" below: Example: What do you think this program will do when you click the "play" button?<jupyter_code>message = "Hello Python world!"
print(message)<jupyter_output><empty_output><jupyter_text>You can change the value of a variable at any time, as I do here:<jupyter_code>message = "Hello Python world!"
print(message)

message = "Python is my favorite language!"
print(message)<jupyter_output>Hello Python world!
Python is my favorite language!<jupyter_text>Common Errors--- Naming rules- Variables can only contain letters, numbers, and underscores. Variable names can start with a letter or an underscore, but can not start with a number. For example, "student_1" and "Student1" would be fine but "1_student" and "?student" would be bad.- Spaces are not allowed in variable names, so we use underscores instead of spaces. For example, use student_name instead of "student name".- You cannot use [Python keywords](http://docs.python.org/3/reference/lexical_analysis.htmlkeywords) as variable names.- Variable names should be descriptive, without being too long. For example mc_wheels is better than just "wheels", and number_of_wheels_on_a_motorycle.- Be careful about using the lowercase letter l and the uppercase letter O in places where they could be confused with the numbers 1 and 0.  NameErrorThere is one common error when using variables, that you will almost certainly encounter at some point. Take a look at this code, and see if you can figure out why it causes an error.<jupyter_code>message = "Thank you for sharing Python with the world, Guido!"
print(message)<jupyter_output>Thank you for sharing Python with the world, Guido!<jupyter_text>Let's look through this error message. First, we see it is a NameError. Then we see the file that caused the error, and a green arrow shows us what line in that file caused the error. Then we get some more specific feedback, that "name 'mesage' is not defined".You may have already spotted the source of the error. We spelled message two different ways. Python does not care whether we use the variable name "message" or "mesage". Python only cares that the spellings of our variable names match every time we use them.This is pretty important, because it allows us to have a variable "name" with a single name in it, and then another variable "names" with a bunch of names in it.We can fix NameErrors by making sure all of our variable names are spelled consistently.<jupyter_code>message = "Thank you for sharing Python with the world, Guido!"
print(message)<jupyter_output><empty_output><jupyter_text>Syntax ErrorAnother error that we'll often get when we type something wrong is a syntax error. This clues us in that perhaps we are missing a quotation mark, a parenthesis, or some other type of incorrect typing. For example:<jupyter_code>print('hello')<jupyter_output>hello<jupyter_text>Exercise - Friend Name: Store your name in a variable called "myname" and a friend's name in a variable called "friendname." Then print both names.<jupyter_code>myname = "Jonathan"
friendname = "Gooboo Mc"
print(myname)
print(friendname)<jupyter_output>Jonathan
Gooboo ADFS<jupyter_text>Strings---Strings are sets of characters. Strings are easier to understand by looking at some examples.  Single and double quotesStrings are contained by either single or double quotes.<jupyter_code>my_string = "This is a double-quoted string."
my_string = 'This is a single-quoted string.'<jupyter_output><empty_output><jupyter_text>Typically, we can use either. However, if you want to contain a quote within the parenthesis, then you will need to use double quotes. For example:<jupyter_code>quote = "<NAME> once said, 'Any program is only as good as it is useful.'"
print(quote)<jupyter_output><NAME> once said, 'Any program is only as good as it is useful.'<jupyter_text>Changing caseYou can easily change the case of a string, to present it the way you want it to look.<jupyter_code>first_name = 'eric'

print(first_name)
print(first_name.title())<jupyter_output>eric
Eric<jupyter_text>It is often good to store data in lower case, and then change the case as you want to for presentation. This catches some Typos. It also makes sure that 'eric', 'Eric', and 'ERIC' are not considered three different people.Some of the most common cases are lower, title, and upper.<jupyter_code>first_name = 'eric'

print(first_name)
print(first_name.title())
print(first_name.upper())

first_name = 'Eric'
print(first_name.lower())<jupyter_output>eric
Eric
ERIC
eric<jupyter_text>You will see this syntax quite often, where a variable name is followed by a dot and then the name of an action, followed by a set of parentheses. The parentheses may be empty, or they may contain some values.variable_name.action()In this example, the word "action" is the name of a method. A method is something that can be done to a variable. The methods 'lower', 'title', and 'upper' are all functions that have been written into the Python language, which do something to strings. Later on, you will learn to write your own methods.  Combining strings (concatenation)It is often very useful to be able to combine strings into a message or page element that we want to display. Again, this is easier to understand through an example.<jupyter_code>dog = 'Maeby'
cat = 'Tobias'
print("My dog's name is " + dog + " and my cat's name is " + cat + '.')<jupyter_output>My dog's name is Maeby and my cat's name is Tobias.<jupyter_text>Notice that I needed to be careful to add spaces after the word "is" in order for there to be spaces between the phrases. Quotation marks do not automatically add a space between each phrase, whereas commas do add spaces:<jupyter_code>dog = 'Maeby'
cat = 'Tobias'
print("My dog's name is", dog, "and my cat's name is", cat, '.')<jupyter_output>My dog's name is Maeby and my cat's name is Tobias .<jupyter_text>Notice that in the above example, there was an unnecessary space after "Tobias", since commas always add an extra space. To rectify this, we could change the last comma to a +:<jupyter_code>dog = 'Maeby'
cat = 'Tobias'
print("My dog's name is", dog, "and my cat's name is", cat + '.')<jupyter_output>My dog's name is Maeby and my cat's name is Tobias.<jupyter_text>Below is another concatenation example:<jupyter_code>first_name = 'ada'
last_name = 'lovelace'

full_name = first_name + ' ' + last_name

print(full_name)
print(full_name.title())<jupyter_output>ada lovelace
Ada Lovelace<jupyter_text>The plus sign combines two strings into one, which is called "concatenation". You can use as many plus signs as you want in composing messages. In fact, many web pages are written as giant strings which are put together through a long series of string concatenations.<jupyter_code>first_name = 'ada'
last_name = 'lovelace'
full_name = first_name + ' ' + last_name

message = "The daughter of famed poet Lord Byron, " + full_name.title() + ' ' + ", was considered the world's first computer programmer."

print(message)<jupyter_output>The daughter of famed poet Lord Byron, Ada Lovelace , was considered the world's first computer programmer.<jupyter_text>If you don't know who Ada Lovelace is, you might want to go read what Wikipedia or the Computer History Museum have to say about her. Her life and her work are also the inspiration for the Ada Initiative, which supports women who are involved in technical fields.  f-stringsNew in Python 3.6 is a way to mix variables and code and strings together.  This will become very useful when you want to print out a mixture of text, the content of variables and maybe even the output of some code.An f-string works like this:<jupyter_code>favorite_color = 'orange' # this is just a variable storing a color

print(f"My favorite color is {favorite_color}.")
print(f"My favorite color is {favorite_color.title()}.")
print(f"My favorite color is {favorite_color.upper()}.")
print(f"My favorite color is {((favorite_color + ' ') * 5).upper()}")<jupyter_output><empty_output><jupyter_text>When you run the code above, notice what happens.  This functionality may save you a lot of time in the future.   Exercise - Full NameStore your first name and last name in separate variables, and then combine them to print out your full name three times:    - Use commas in one line    - plus signs in another line    - use an f-string for the third lineMake sure there is a space between your first and last name.<jupyter_code>firstname = "jonathan"
lastname = "oppenheimer"

print(firstname.title(), lastname.title())
print(firstname.title() + ' ' + lastname.title())
print(f"{firstname.title()} {lastname.title()}")<jupyter_output><NAME>
<NAME>
<NAME><jupyter_text>Exercise - Full Name CapitalizedStore your first name and last name in separate variables, and then combine them to print out your full name. Print your full name in lowercase, Titlecase, and UPPERCASE.<jupyter_code>firstname = "jonathan"
lastname = "oppenheimer"
print(f"{firstname} {lastname}")
print(f"{firstname.title()} {lastname.title()}")
print(f"{firstname.upper()} {lastname.upper()}")<jupyter_output><NAME>
<NAME>
JONATHAN OPPENHEIMER<jupyter_text>Exercise - Family NamesWrite a program that stores all of the names of the people in your household separately and all of the pets. Then it should print out a complete sentence describing your household. For example, my program would print out: "Lauren and Paul live with their dogs Maeby and Suby."<jupyter_code>myname = "jonathan"
fathername = "Peter"
mothername = "Stephanie"
brothername = "Danny"
dogname= "Emmie"

print(f"{myname.title()}, {fathername.title()}, {mothername.title()}, and {brothername.title()} live with their dog {dogname.title()}.")<jupyter_output>Jonathan, Peter, Stephanie, and Danny live with their dog Emmie.<jupyter_text>Exercise - MoviesWrite a program that stores three of your favorite movies in lowercase. Then, it should print out a complete sentence describing your movie preference. Use the command .upper() to make your entire message in caps. For example, my program would print out "MATT'S FAVORITE MOVIES ARE OLD SCHOOL, OFFICE SPACE, AND ETERNAL SUNSHINE OF THE SPOTLESS MIND." Remember what type of quotations you need in order to print out a quotation.<jupyter_code>movie1 = "big dab"
movie2 = "big dab moves to new york"
movie3 = "big dab dies in a trailer park"

print(f"jonathan's favorite movies are {movie1}, {movie2}, and {movie3}.".upper())<jupyter_output>JONATHAN'S FAVORITE MOVIES ARE BIG DAB, BIG DAB MOVES TO NEW YORK, AND BIG DAB DIES IN A TRAILER PARK.<jupyter_text>White Space---The term "whitespace" refers to characters that the computer is aware of, but are invisible to readers. The most common whitespace characters are spaces, tabs, and newlines.Spaces are easy to create, because you have been using them as long as you have been using computers. Tabs and newlines are represented by special character combinations.The two-character combination "\t" makes a tab appear in a string. Tabs can be used anywhere you like in a string.<jupyter_code>print("Hello everyone!")
print("\t Hello everyone!")
print("Hello \t everyone!")<jupyter_output>Hello 	 everyone!<jupyter_text>The combination "\n" makes a newline appear in a string. You can use newlines anywhere you like in a string.<jupyter_code>print("Hello \neveryone!")
print("Hello \n\neveryone!")
print("\n\n\nHello everyone!")<jupyter_output>Hello everyone!<jupyter_text>Stripping WhitespaceMany times you will allow users to enter text into a box, and then you will read that text and use it. It is really easy for people to include extra whitespace at the beginning or end of their text. Whitespace includes spaces, tabs, and newlines.It is often a good idea to strip this whitespace from strings before you start working with them. For example, you might want to let people log in, and you probably want to treat 'eric ' as 'eric' when you are trying to see if I exist on your system.You can strip whitespace from the left side, the right side, or both sides of a string.<jupyter_code>name = ' eric '

print(name.lstrip())
print(name.rstrip())
print(name.strip())<jupyter_output>eric 
 eric
eric<jupyter_text>It's hard to see exactly what is happening, so maybe the following will make it a little more clear:<jupyter_code>name = ' eric '
print(f"-{name}-")
print('-' + name.lstrip() + '-')
print('-' + name.rstrip() + '-')
print('-' + name.strip() + '-')<jupyter_output>- eric -
-eric -
- eric-
-eric-<jupyter_text>Exercise - Someone SaidFind a quote that you like. Store the quote in a variable, with an appropriate introduction such as "<NAME> once said, 'One of my most productive days was throwing away 1000 lines of code'". Print the quote.<jupyter_code>quote = "'One of my most productive days was throwing away 1000 lines of code'"
print(f"<NAME> once said, {quote}")<jupyter_output><NAME> once said, 'One of my most productive days was throwing away 1000 lines of code'<jupyter_text>Exercise - Name Strip- Store your first name in a variable, but include at least two kinds of whitespace on each side of your name.- Print your name as it is stored.- Print your name with whitespace stripped from the left side, then from the right side, then from both sides.<jupyter_code>name = "              jonathan"
print(f"{name}")
print(f"{name.strip()}")<jupyter_output>jonathan
jonathan<jupyter_text>Numbers---Dealing with simple numerical data is fairly straightforward in Python, but there are a few things you should know about.  IntegersYou can do all of the basic operations with integers, and everything should behave as you expect. Addition and subtraction use the standard plus and minus symbols. Multiplication uses the asterisk, and division uses a forward slash. Exponents use two asterisks.<jupyter_code>print(3+2)
print(3-2)
print(3*2)
print(3/2)
print(3**2)<jupyter_output>5
1
6
1.5
9<jupyter_text>You can use parenthesis to modify the standard order of operations.<jupyter_code>first_order = 2+(3*4)
second_order = (2+3)*4
print(first_order, second_order)<jupyter_output>14 20<jupyter_text>Floating-Point numbersFloating-point numbers refer to any number with a decimal point. Most of the time, you can think of floating point numbers as decimals, and they will behave as you expect them to.<jupyter_code>print(0.1+0.1)
print(0.1+0.2)<jupyter_output>0.30000000000000004<jupyter_text>This happens because of the way computers represent numbers internally; this has nothing to do with Python itself. Basically, we are used to working in powers of ten, where one tenth plus two tenths is just three tenths. But computers work in powers of two. So your computer has to represent 0.1 in a power of two, and then 0.2 as a power of two, and express their sum as a power of two. There is no exact representation for 0.3 in powers of two, and we see that in the answer to 0.1+0.2.Python tries to hide this kind of stuff when possible. Don't worry about it much for now; just don't be surprised by it, and know that we will learn to clean up our results a little later on.You can also get the same kind of result with other operations.<jupyter_code>print(3*0.1)<jupyter_output>0.30000000000000004<jupyter_text>Division was a little bit funnier in the older versions of Python. If we divided 3 by 2 in earlier versions of Python, we wouldn't get out 1.5, but instead 1, since Python 2 always rounded down to the nearest integer. However, we'll be using Python 3 in this course, and division works the way you would expect:<jupyter_code># Python 3.x
print(3/2)<jupyter_output>1.5<jupyter_text>We can write programs that store several variables and then perform a calculation on them. For example, the code below calculates the number of seconds in a year:<jupyter_code>days = 365
hours = 24
minutes = 60
seconds = 60
print(days*hours*minutes*seconds)

# or better
print(f"There are {days*hours*minutes*seconds} seconds in a year!")

# or even better!
print(f"There are {days*hours*minutes*seconds:,} seconds in a year!")<jupyter_output>31536000
There are 31,536,000 seconds in a year!
There are 31,536,000 seconds in a year!<jupyter_text>Concatenating Strings and NumbersRecall that you could use commas or plus signs to combine words together; commas added spaces automatically, and plus signs didn't. We have to be a bit more careful when we try to combine a number and a string in the same sentence. For example, a comma works in the following code:<jupyter_code>print('High', 5)<jupyter_output>High 5<jupyter_text>However, a plus sign would not, as you can't add a word and a number:<jupyter_code>print('High'+5)<jupyter_output><empty_output><jupyter_text>How can you get around this? Specifically tell the computer to treat 5 as a string. Then, you can use a + sign:<jupyter_code>print('High ' + str(5))<jupyter_output>High 5<jupyter_text>Exercise - ArithmeticStore the results of four different calculations in separate variables. Make sure you use each operation at least once.Then print a series of informative statements, such as "The result of the calculation 2^3 is 8."<jupyter_code>calc1 = 3**3
calc2 = 3+3
calc3 = 3-3 
calc4 = 3*3

print(f"3^3 is {calc1}.")
print(f"3+3 is {calc2}.")
print(f"3-3 is {calc3}.")
print(f"3*3 is {calc4}.")<jupyter_output>3^3 is 27.
3+3 is 6.
3-3 is 0.
3*3 is 9.<jupyter_text>Exercise - Long Decimals- On paper, 0.1+0.2=0.3. But you have seen that in Python, 0.1+0.2=0.30000000000000004.- Find at least one other calculation that results in a long decimal like this.<jupyter_code>#insert long decimals code here
print(f"{3*0.1}")<jupyter_output>0.30000000000000004<jupyter_text>Exercise  - SecondsWrite a program that counts the number of seconds in a 72 year old's life span and prints out a statement summarizing your findings.<jupyter_code>calc1 = 72 * 365 * 24 * 60 * 60
print(f"There are {calc1:,} seconds in a 72 year old's life span.")<jupyter_output>There are 2,270,592,000 seconds in a 72 year old's life span.<jupyter_text>Exercise - Fave word and numberWrite a program that prints your favorite word and your favorite number on the same line. Do this twice - once using a comma and once using a plus sign to separate them.<jupyter_code>favword = "dab"
favnumber = 69
print(favword, favnumber)
print(favword + ' ' + str(favnumber))<jupyter_output>dab 69
dab 69<jupyter_text>User Input--- Up until now, we have specified variables only once and haven't been able to change them much. For example, if I wanted to store my name, I might make a variable called name:<jupyter_code>name = 'Lauren'
print(name)<jupyter_output><empty_output><jupyter_text>However, this isn't very exciting, as the name never changes. Instead, we can ask the user (i.e., whoever is typing on the computer) for their name, and our program will print out their name instead. Let's see how this works. Run the code below and then type in your name.<jupyter_code>name = input('What is your name? ')
print(name)<jupyter_output><empty_output><jupyter_text>As another example, suppose we wanted to ask the user for their pet's name and then read it back to them. We could type:<jupyter_code>pet = input("What is your pet's name? ")
print(f"Your pet's name is {pet}.")<jupyter_output><empty_output><jupyter_text>Length of a StringWe can also calculate the length of a string using len(). For example:<jupyter_code>string='abcdefghijklmnopqrstuvwxyz'
print(len(string))<jupyter_output>26<jupyter_text>Exercise - Name?Write a program that asks the user for their name, and then prints out a statement confirming their name in quotation marks. For example, if the user typed in 'Lauren', the program should return:```What is your name? LaurenDid you say your name was 'Lauren'? ```<jupyter_code>#insert name? code here
name =input("What is your name?")
print(f'Did you say you name was {name}')<jupyter_output>What is your name?dasjklf;
Did you say you name was dasjklf;<jupyter_text>Exercise - Full nameWrite a program that asks for the user's first name, and then replies back asking for their last name by mentioning their first name in the question. Then, the program should print out the full name. For example, the program would work like:```What is your first name? LaurenWhat is your last name, Lauren? ShareshianYour full name is <NAME>.```<jupyter_code>name =input("What is your name?")
lastname =input(f"What is your last name, {name.title()}?")
print(f"Your full name is {name.title()} {lastname.title()}.")<jupyter_output>What is your name?billy
What is your last name, Billy?sammy
Your full name is <NAME>.<jupyter_text>Exercise - Three FriendsWrite a program that asks for the names of your three friends and then prints out a greeting for each of them. For example, the program might work like:```Friend1: TreyFriend2: MikeFriend3: PageHello, Trey!What's up, Mike?Hola, Page!```<jupyter_code>friend1=input(f"Name a friend.")
friend2=input(f"Name a friend.")
friend3=input(f"Name a friend.")
print(f"Hello, {friend1.title()}!")
print(f"What's up, {friend3.title()}?")
print(f"Hola, {friend2.title()}!")<jupyter_output>Name a friend.sam
Name a friend.jkdlafs
Name a friend.jfad
Hello, Sam!
What's up, Jfad?
Hola, Jkdlafs!<jupyter_text>Exercise - Length of NameWrite a program that asks for the user's name and then prints out the length of their name. Then the program should return a sentence about the length of their name. For example, it should print "The length of Lauren is 6."<jupyter_code>name=input("What is your name?")
print(f"The length of {name} is {len(name)}.")<jupyter_output>What is your name?bam
The length of bam is 3.<jupyter_text>Numerical User Input---Up until now, we have only requested string input from a user. What if we want to request a number? You'll need to put int() around the input code. This specifies that we are requesting an integer, not a word. The example below prints out double the user's number.<jupyter_code>number = int(input('What is your favorite number? '))
print(2*number)<jupyter_output><empty_output><jupyter_text>What if you wanted to request a decimal? Then put float() around the input code. For example:<jupyter_code>number = float(input('What is your favorite number? '))
print(2*number)<jupyter_output><empty_output><jupyter_text>Let's see what would happen if we didn't put int() around the above code and we multiplied it by 2:<jupyter_code>number = input('What is your favorite number? ')
print(2*number)<jupyter_output>What is your favorite number? h
hh<jupyter_text>What happened? Well, right now, the computer is treating the variable "number" as a string. In Python, a string times a number just repeats the string that many times. For example:<jupyter_code>repeat = 3
message = 'hello'
print(repeat*message)<jupyter_output>hellohellohello<jupyter_text>Updating a Numerical VariableRecall that we can always update a variable to be something else. We often do this when we want to simplify our code by not having more variables than necessary. For example, suppose we wanted to ask the user for a number and return 1 greater than that number. We could type the long way:<jupyter_code>number = int(input('What is your number? '))
new_number = number + 1
print(new_number)<jupyter_output><empty_output><jupyter_text>However, we really didn't need to introduce another variable called new_number. Instead, we could have just updated our old variable:<jupyter_code>number = int(input('What is your number? '))
print(number+1)<jupyter_output><empty_output><jupyter_text>Exercise - ExponentiateWrite a program that asks the user for a number and returns 2 raised to that number. For example, entering 3 would return 8.<jupyter_code>number = int(input("Name a number."))
print(f"{2**number}")<jupyter_output>Name a number.6
64<jupyter_text>Exercise - MultiplicationWrite a program that asks the user for two numbers and then prints out the product in a complete sentence. For example, the program might look like:```First number: 5Second number: 3The product of 3 times 5 is 15.```<jupyter_code>number1 = int(input("Name a number."))
number2 = int(input("Name another number."))
print(f"The product of {number1} and {number2} is {number1*number2}")<jupyter_output>Name a number.7
Name another number.7
The product of 7 and 7 is 49<jupyter_text>Exercise - RepeaterWrite a program that asks a user for a phrase and the number of times the user wants that phrase repeated. Then print out the repeated phrase.<jupyter_code>phrase=input("name a phrase fool.")
number=int(input("name a number fool."))
print(f"{phrase}"*number)<jupyter_output>name a phrase fool.adslhkjf
name a number fool.7
adslhkjfadslhkjfadslhkjfadslhkjfadslhkjfadslhkjfadslhkjf<jupyter_text>Exercise - Happy EmoticonWe can make a smile using underscores sandwiched between two carrot symbols. Write a program that asks the user how happy they are and prints that many underscores between the carrots. For example, the program might look like:```How happy are you? 5^_ _ _ _ _^```<jupyter_code>number = int(input("How happy are you on a scale of 1 from ∞."))
print(f"^{'_'*number}^")<jupyter_output>How happy are you on a scale of 1 from ∞.50
^__________________________________________________^<jupyter_text>Exercise - temperatureWrite a program that asks the user for a temperature in degrees Celsius and converts it to Fahrenheit. Recall that the conversion formula is F = (9/5)*C+32<jupyter_code>number=float(input("What is the temperature in degrees Celsius?"))
print(f"{(9/5)*number+32}")<jupyter_output>What is the temperature in degrees Celsius?76.5
169.70000000000002<jupyter_text>Exercise - updating variableWrite a program that asks a user for a number. Then, double that number. Then, add one to that number. Then, square that number. Do all of these operations by updating the user's number as a new value, rather than by introducing new variables.<jupyter_code>number=float(input("Name a number."))
number=number*2
number=number+1
number=number**2
print(number)<jupyter_output>Name a number.2
25.0<jupyter_text>Comments---As you begin to write more complicated code, you will have to spend more time thinking about how to code solutions to the problems you want to solve. Once you come up with an idea, you will spend a fair amount of time troubleshooting your code, and revising your overall approach.Comments allow you to write in English, within your program. In Python, any line that starts with a pound () symbol is ignored by the Python interpreter.<jupyter_code># The code below cubes a number
print (2**3) # To rais a number to a power, use the ** symbol not the ^ symbol<jupyter_output><empty_output><jupyter_text>What makes a good comment?---- It is short and to the point, but a complete thought. Most comments should be written in complete sentences.- It explains your thinking, so that when you return to the code later you will understand how you were approaching the problem.- It explains your thinking, so that others who work with your code will understand your overall approach to a problem.- It explains particularly difficult sections of code in detail.When should you write comments?---- When you have to think about code before writing it.- When you are likely to forget later exactly how you were approaching a problem.- When there is more than one way to solve a problem.- When others are unlikely to anticipate your way of thinking about a problem.Writing good comments is one of the clear signs of a good programmer. If you have any real interest in taking programming seriously, start using comments now. You will see them throughout the examples in these notebooks.  Exercise - First CommentsChoose the longest, most difficult, or most interesting program you have written so far. Copy the program here and write at least one comment in your program.<jupyter_code>#juptyr is gay<jupyter_output><empty_output><jupyter_text>Introduction to Lists---A list is a collection of items, that is stored in a variable. The items should be related in some way, but there are no restrictions on what can be stored in a list. Here is a simple example of a list, and how we can quickly access each item in the list. Naming and defining a listSince lists are collection of objects, it is good practice to give them a plural name. If each item in your list is a car, call the list 'cars'. If each item is a dog, call your list 'dogs'. This gives you a straightforward way to refer to the entire list ('dogs'), and to a single item in the list ('dog').In Python, square brackets designate a list. To define a list, you give the name of the list, the equals sign, and the values you want to include in your list within square brackets.<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']
print(dogs)<jupyter_output>['border collie', 'australian cattle dog', 'labrador retriever']<jupyter_text>Accessing one item in a listItems in a list are identified by their position in the list, starting with zero. This will almost certainly trip you up at some point. Programmers even joke about how often we all make "off-by-one" errors, so don't feel bad when you make this kind of error.To access the first element in a list, you give the name of the list, followed by a zero in brackets.<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']

dog = dogs[0]
print(dog)
print(dog.title())<jupyter_output>border collie
Border Collie<jupyter_text>The number in parentheses is called the **index** of the item. Because lists start at zero, the index of an item is always one less than its position in the list. So to get the second item in the list, we need to use an index of 1.<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']

dog = dogs[1]
print(dog.title())<jupyter_output><empty_output><jupyter_text>Accessing the last items in a listYou can probably see that to get the last item in this list, we would use an index of 2. This works, but it would only work because our list has exactly three items. To get the last item in a list, no matter how long the list is, you can use an index of -1.<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']

dog = dogs[-1]
print(dog.title())<jupyter_output><empty_output><jupyter_text>This syntax also works for the second to last item, the third to last, and so forth.<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']

dog = dogs[-2]
print(dog.title())<jupyter_output><empty_output><jupyter_text>You can't use a negative number larger than the length of the list, however.<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']

dog = dogs[-4]
print(dog.title())<jupyter_output><empty_output><jupyter_text>Editing Lists--- Lists are MutableLists are mutable, meaning that we can change items in the list. For example, suppose we create the list of dogs 'border collie', 'australian cattle dog', and 'labrador retriever', but we want to change the australian cattle dog to a pit bull. Look at what the following code does:<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']
print(dogs)
dogs[1]='pit bull'
print(dogs)<jupyter_output>['border collie', 'australian cattle dog', 'labrador retriever']
['border collie', 'pit bull', 'labrador retriever']<jupyter_text>Finding an indexWe can use .index() to find the location of an element in a list. Look at the following code:<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']
print(dogs.index('border collie'))
print(dogs.index('australian cattle dog'))
print(dogs.index('labrador retriever'))<jupyter_output>0
1
2<jupyter_text>Exercise - New Best FriendWrite a program that saves a list of your friends. Uh oh - you got into a fight with one of your friends and replaced them with a new one. Update your friend list accordingly. Print each friend's name and their index in a sentence. For example, one sentence might by "My friend Jane is in Index 2."<jupyter_code>friends = ['bill', 'bam', 'bing', 'bop']
print(friends)
friends[2]='uhoh'
print(friends)<jupyter_output>['bill', 'bam', 'bing', 'bop']
['bill', 'bam', 'uhoh', 'bop']<jupyter_text>Exercise - RaceJane, Jack, and Sue are saved in a race list. Jane came in first place, Jack came in second, and Sue came in third. Write a program that uses the index command to print out the results. For example, the first line should say "Jane is in: Place 1." Hint: you may need to add by 1 somewhere since Jane is technically in the 0 index.<jupyter_code>race =['Jane', 'Jack', 'Sue']
print(f"Jane came in {race.index('Jane')+1}, Jack came in {race.index('Jack')+1}, and Sue came in {race.index('Sue')+1}")<jupyter_output>Jane came in 1, Jack came in 2, and Sue came in 3<jupyter_text>Adding items to a list---We can add items to a list by using the append command. Suppose I want to adopt two more dogs, a pit bull and a boxer. I can use the following code:<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']
dogs.append('pit bull')
dogs.append('boxer')
print(dogs)<jupyter_output><empty_output><jupyter_text>Creating an empty listSuppose we start out with no dogs at our house. Then, we start going to the shelter (until our husband stops us!) to adopt more dogs. In this case, we'll start out with an empty dog list and then add dogs as we go. To do this, use the following code:<jupyter_code>dogs = []
dogs.append('pit bull')
dogs.append('boxer')
dogs.append('labrador')
print(dogs)<jupyter_output><empty_output><jupyter_text>Sorting a List---We want to sort a list of students in alphabetical order. We might try this code:<jupyter_code>students = ['James', 'Abby', 'Zach', 'Brandy', 'Mitch']
print(students.sort())<jupyter_output><empty_output><jupyter_text>Uh oh, this isn't what we want. We actually need to sort the list before we print it. Type:<jupyter_code>students = ['James', 'Abby', 'Zach', 'Brandy', 'Mitch']
students.sort()
print(students)<jupyter_output>['Abby', 'Brandy', 'James', 'Mitch', 'Zach']<jupyter_text>We can even go in reverse order.<jupyter_code>students = ['James', 'Abby', 'Zach', 'Brandy', 'Mitch']
students.sort(reverse = True)
print(students)<jupyter_output>['Zach', 'Mitch', 'James', 'Brandy', 'Abby']<jupyter_text>Exercise - Make New FriendsMake a list of some of your friends. Great! Now, you've made some new friends. Add them to the list, too.<jupyter_code>friends = ['a', 'b', 'c']
print(friends)
friends.append('d')
friends.append('e')
friends.append('f')
print(friends)<jupyter_output>['a', 'b', 'c']
['a', 'b', 'c', 'd', 'e', 'f']<jupyter_text>Exercise - Alphabetical New FriendsSort your friends from the Make New Friends exercise in both orders.<jupyter_code>friends = ['a', 'b', 'c']
print(friends)
friends.append('d')
friends.append('e')
friends.append('f')
print(friends)
friends.sort()
print(friends)<jupyter_output>['a', 'b', 'c']
['a', 'b', 'c', 'd', 'e', 'f']
['a', 'b', 'c', 'd', 'e', 'f']<jupyter_text>Removing items from a list---There are several different ways to remove items from a list. These include remove, pop, and delete.  Removing items by positionSuppose we have four items in a list and we want to remove the third. We can do that by using the delete function and specifying that we want to remove the item in the third index:<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever', 'pit bull']
del dogs[2]

print(dogs)<jupyter_output>['border collie', 'australian cattle dog', 'pit bull']<jupyter_text>Removing items by valueYou can also remove an item from a list if you know its value. To do this, we use the *remove()* function. Give the name of the list, followed by the word remove with the value of the item you want to remove in parentheses. Python looks through your list, finds the first item with this value, and removes it.<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever', 'pit bull']
dogs.remove('labrador retriever')
print(dogs)<jupyter_output>['border collie', 'australian cattle dog', 'pit bull']<jupyter_text>Just be careful, though, because using the remove command only removes the first instance of an item. If that item appears multiple times in your list, it will only remove the first:<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever', 'pit bull', 'labrador retriever']
dogs.remove('labrador retriever')
print(dogs)<jupyter_output><empty_output><jupyter_text>Popping items in a listPython has a third function that not only removes an item from the list, but also "returns" the item so that we can work with it if we want to. If you don't specify the index of the item that you want to remove, then by default, it will remove the last item in your list.  Consider the following code:<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']
last_dog = dogs.pop() # .pop "returns" the last element, and we save it to "last_dog"

print(last_dog)
print(dogs)<jupyter_output><empty_output><jupyter_text>However, if I wanted to remove the second dog from the list instead, I could specify index = 1 in the pop argument:<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']
last_dog = dogs.pop(1)

print(last_dog)
print(dogs)<jupyter_output>australian cattle dog
['border collie', 'labrador retriever']<jupyter_text>Exercise - Fight with friendsMake a list of five friends. Suppose you get into a fight with the third friend in your list. Use the pop function to delete that friend from your friend list. Then print out a statement that says that the person is not your friend anymore. For example, if your friends are Jack, Jane, Sue, Alan, and Rick, you should remove Sue from the list and then say, "Sue, you are not my friend!" using the variable stored from using pop.<jupyter_code>friends = ['Jack', 'Jane', 'Sue', 'Alan', 'Rick']
print(friends)
friend_removed = friends.pop(2)
print(f"{friend_removed}, you are not my friend!")
print(friends)<jupyter_output>['Jack', 'Jane', 'Sue', 'Alan', 'Rick']
Sue, you are not my friend!
['Jack', 'Jane', 'Alan', 'Rick']<jupyter_text>Exercise - Fight with friends againMake a list of five friends. Remove one of them by name using the remove command.<jupyter_code>friends = ['Jack', 'Jane', 'Sue', 'Alan', 'Rick']
print(friends)
friends.remove('Sue')
print(friends)<jupyter_output>['Jack', 'Jane', 'Sue', 'Alan', 'Rick']
['Jack', 'Jane', 'Alan', 'Rick']<jupyter_text>Length of a List--- The length of a list can be obtained by typing len() around the list:<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']
print(len(dogs))<jupyter_output><empty_output><jupyter_text>Thus, len provides another way for us to reference the last dog in the list:  Exercise - Last CrayonWrite a program that saves four colors in a list called colors. Use both the -1 method and the length method to print the last color in the list two different ways.<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']
print(dogs[len(dogs)-1])<jupyter_output>labrador retriever<jupyter_text>Wait - why did we have to use the index len(dogs)-1 instead of just len(dogs)? Remember - although there are three dogs in the list, they are referenced by the indices 0, 1, and 2. Thus, there is no dog in the index = 3 position.<jupyter_code>crayons = ['red','green','blue']
print(crayons[len(crayons)-1])<jupyter_output>blue<jupyter_text>Exercise - Three moviesStore your favorite movies in a list. Print each movie in a separate complete sentence. In the last sentence, specify how many favorite movies you have, using the length function. For example, my code might read:```One of my favorite movies is Old School.One of my favorite movies is Eternal Sunshine.One of my favorite movies is Blair Witch.I have 3 favorite movies.```<jupyter_code>movies = ["Eternal Sunhsine", "Interstellar", "Monty Python and the Holy Grail"]
print(f"One of my favorite movies is {movies[0]}")
print(f"One of my favorite movies is {movies[1]}")
print(f"One of my favorite movies is {movies[2]}")
print(f"I have {len(movies)} favorite movies.")<jupyter_output>One of my favorite movies is Eternal Sunhsine
One of my favorite movies is Interstellar
One of my favorite movies is Monty Python and the Holy Grail
I have 3 favorite movies.<jupyter_text>Looping Through Lists---We can use a for loop to print out every item in a list on a separate line:<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']
for dog in dogs:
    print(dog)
    
print(f'I have {len(dogs)} favorite dogs.')<jupyter_output>border collie
australian cattle dog
labrador retriever
I have 3 favorite dogs.<jupyter_text>We have already seen how to create a list, so we are really just trying to understand how the last two lines work. These last two lines make up a loop, and the language here can help us see what is happening:    for dog in dogs:- The keyword "for" tells Python to get ready to use a loop.- The variable "dog", with no "s" on it, is a temporary placeholder variable. This is the variable that Python will place each item in the list into, one at a time.- The first time through the loop, the value of "dog" will be 'border collie'.- The second time through the loop, the value of "dog" will be 'australian cattle dog'.- The third time through, "dog" will be 'labrador retriever'.- After this, there are no more items in the list, and the loop will end.Note that our program would have worked no matter what we had called the variable meant to reference each dog in the list dogs. The singular "dog" is only an indexing variable, we could have just as easily called it "pet":<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']
for pet in dogs:
    print(pet)<jupyter_output>border collie
australian cattle dog
labrador retriever<jupyter_text>What wouldn't have worked, however, is if we printed "dogs" instead of "dog". A common looping errorOne common looping error occurs when instead of using the single variable *dog* inside the loop, we accidentally use the variable that holds the entire list:<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']

for dog in dogs:
    print(dogs)<jupyter_output>['border collie', 'australian cattle dog', 'labrador retriever']
['border collie', 'australian cattle dog', 'labrador retriever']
['border collie', 'australian cattle dog', 'labrador retriever']<jupyter_text>In this example, instead of printing each dog in the list, we print the entire list every time we go through the loop. Python puts each individual item in the list into the variable *dog*, but we never use that variable.  Iterating though sorted lists:Suppose we wanted to go back to our list of students and print each name out in alphabetical order, as well as print out each name in caps. We can use the sorted() command instead of sort():<jupyter_code>students = ['James', 'Abby', 'Zach', 'Brandy', 'Mitch']
for student in sorted(students):
    print(student.upper())<jupyter_output>ABBY
BRANDY
JAMES
MITCH
ZACH<jupyter_text>Doing more with each itemWe can do whatever we want with the value of "dog" inside the loop. In this case, we just print the name of the dog.    print(dog)However, we are not limited to just printing the word dog. We can do whatever we want with this value, and this action will be carried out for every item in the list. Let's say something about each dog in our list.<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']

for dog in dogs:
    print('I like ' + dog + 's.')<jupyter_output>I like border collies.
I like australian cattle dogs.
I like labrador retrievers.<jupyter_text>Inside and outside the loopPython uses indentation to decide what is inside the loop and what is outside the loop. Code that is inside the loop will be run for every item in the list. Code that is not indented, which comes after the loop, will be run once just like regular code.<jupyter_code>dogs = ['border collie', 'australian cattle dog', 'labrador retriever']

for dog in dogs:
    print('I like ' + dog + 's.')
    print('No, I really really like ' + dog +'s!\n')
    
print("\nThat's just how I feel about dogs.")<jupyter_output>I like border collies.
No, I really really like border collies!

I like australian cattle dogs.
No, I really really like australian cattle dogs!

I like labrador retrievers.
No, I really really like labrador retrievers!


That's just how I feel about dogs.<jupyter_text>Notice that the last line only runs once, after the loop is completed. Also notice the use of newlines ("\n") to make the output easier to read. Here's another example to see how indentatation works:<jupyter_code>your_rapper = input('What is your favorite rapper? ')
print("That's cool that your favorite rapper is "+your_rapper + '.')
my_rappers = ['Jay-Z', 'Notorious B.I.G', 'The Roots','Lizzo']

for artist in my_rappers:
    print('I like '+artist+'.')
print('Who else do you like?')<jupyter_output>What is your favorite rapper? a
That's cool that your favorite rapper is a.
I like Jay-Z.
I like Notorious B.I.G.
I like The Roots.
I like Lizzo.
Who else do you like?<jupyter_text>Exercise - colorsMake a list of four colors called "colors". Use a for loop to print out each color on a new line. Do this twice - once using the word "color" as the indexing variable, and once using the word "crayon." You should obtain the same output each time.<jupyter_code>colors = ['red', 'yellow', 'green', 'blue']
for color in colors:
    print(color)
for crayon in colors:
    print(f"\n{crayon}")<jupyter_output>red
yellow
green
blue

red

yellow

green

blue<jupyter_text>Exercise - Proper NounsTake in a list of lower case words that should be capitalized, like "seattle" or "john." Print each word in reverse alphabetical order on a new line, capitalizing the first word of each line. Hint: remember the .title() command.<jupyter_code>words = ['seattle', 'florida', 'andrew', 'god']
for word in sorted(words,reverse=True):
    print(word.title())<jupyter_output>Seattle
God
Florida
Andrew<jupyter_text>Exercise - colors againUse your color list again and a for loop to print the name of the color and the index of the color in each line. For example, one of your lines might read "Red is in the index 0 position." (Hint: Remember how to print words and numbers in the same print statement.)<jupyter_code>colors = ['red', 'yellow', 'green', 'blue']

for color in colors:
    print(f"{color} is in position {str(colors.index(color))}")<jupyter_output>red is in position 0
yellow is in position 1
green is in position 2
blue is in position 3<jupyter_text>Exercise - travelAsk the user for a place they want to visit.Make a list of the places you want to visit.Make a loop printing out the places that you want to visit, in a complete sentence.Write a concluding sentence that says "I love to travel!"<jupyter_code>location = input("Where would you like to visit")
locations = ['dubai', 'canada', 'guam', 'france']
for loc in locations:
    print(f"I would like to visit {loc.title()}.")
print(f"I love to travel!")<jupyter_output>Where would you like to visitadhsf
I would like to visit Dubai.
I would like to visit Canada.
I would like to visit Guam.
I would like to visit France.
I love to travel!<jupyter_text>Common List Operations--- Splitting A String Into A List---As always, programs aren't very exciting if the variables always stay the same. Instead, we might want to ask a user what their favorite colors are, and then print them in a list. However, if the user prints out all of there colors on the same line, we'll need to split the string into a list of words. For example, suppose the user types in "red blue violet." Then we would want the program to output:```What are your favorite colors? red blue violetOne of your favorite colors is red.One of your favorite colors is blue.One of your favorite colors is violet.```To do this, you'll use the .split() command:<jupyter_code>colors = input('What are your favorite colors? ')
your_colors = colors.split()
for color in your_colors:
    print(f'One of your favorite colors is {color}.')<jupyter_output>What are your favorite colors? red green blue violet 
One of your favorite colors is red.
One of your favorite colors is green.
One of your favorite colors is blue.
One of your favorite colors is violet.<jupyter_text>As another example, suppose you wanted the user to give you their favorite three numbers and you return double those numbers. The first line of your program might look like:```What are your favorite numbers? 10 13 101```You could type:<jupyter_code>numbers = input('What are your favorite numbers? ')
your_numbers = numbers.split()
for number in your_numbers:
    print(2*int(number))
print('These are double your numbers.')<jupyter_output>What are your favorite numbers? 7 734 3
14
1468
6
These are double your numbers.<jupyter_text>Wait - why did we need to type int(number) instead of just number? Remember, since we took the user's input in a a single phrase, and .split() broke the phrase up into words, we have to remind Python that each of those words is actually a number. Otherwise, when we multiply by 2, we'll just repeat that number twice, as Python is treating it as a string:<jupyter_code>numbers = input('What are your favorite numbers? ')
your_numbers = numbers.split()
for number in your_numbers:
    print(2*number)
print('These are double your numbers.')<jupyter_output>What are your favorite numbers? 7 79548 4
77
7954879548
44
These are double your numbers.<jupyter_text>Exercise - Class ListWrite a program that takes a list of students and prints out a class list. For example, your program should look like:```Students: <NAME> <NAME>Class ListJackPam AlanBrittanyZachThis is your class!```<jupyter_code>my_class = input("List all the people in your class seperated by a single space.")
my_class = my_class.split()
for people in my_class:
    print(people)
print("This is your class!")<jupyter_output>List all the people in your class seperated by a single space.mna woman me
mna
woman
me
This is your class!<jupyter_text>Exercise - One lessWrite a program that takes a list of numbers and prints out one less than each of those numbers.<jupyter_code>numbers = input("List number sperated by a single space")
numbers = numbers.split()
for number in numbers:
    print(f"{2*int(number)}")<jupyter_output>List number sperated by a single space4 5 3
8
10
6<jupyter_text>Exercise - exerciseWrite a program that asks the user which days they exercised, and then tells them how many days they did and did NOT exercise. For example, your output should look like:```Which days did you exercise? Monday Wednesday ThurdayDays you exercised: 3Days you were lazy: 4```<jupyter_code>days = input("What days did you exercise for?")
days = days.split()
print(f"Days you exercised: {len(days)}")
print(f"Days you were lazy: {7-len(days)}")<jupyter_output>What days did you exercise for?a b c 
Days you exercised: 3
Days you were lazy: 4<jupyter_text>Using Lists to Update Strings---Suppose we have a list of words and we want to print them out on one line. We can do that using a for loop and by initializing an empty string. Each time we enter the loop, we'll add another word to the string. For example, in the code below I'll print out all of the colors on one line and the length of the string we created:<jupyter_code>colors = ['red', 'blue', 'green']
color_phrase = ''
for color in colors:
    color_phrase = color_phrase + color + ' '
print(color_phrase)
print(len(color_phrase))<jupyter_output>red blue green 
15<jupyter_text>Notice - the words red, blue, green, and the spaces between them add up to 14 characters. Why is the length 15? Because there is an extra space at the end for the last time it added a + ' ' in the loop. If we want to delete that, remember we can use the .rstrip() command to strip the whitespace from the right hand side. Type:<jupyter_code>colors = ['red', 'blue', 'green']
color_phrase = ''
for color in colors:
    color_phrase = color_phrase + color + ' '
color_phrase = color_phrase.rstrip()
print(color_phrase)
print(len(color_phrase))<jupyter_output>red blue green
14<jupyter_text>As another example, suppose we want to print out the numbers 1 through 5 on a line separated by a space, but deleting the extra space at the end. We could type:<jupyter_code>numbers = [1, 2, 3, 4, 5]
number_phrase = ''
for number in numbers:
    number_phrase = number_phrase + str(number) + ' '
number_phrase = number_phrase.rstrip()
print(number_phrase)<jupyter_output>1 2 3 4 5<jupyter_text>A second way to print things on the same lineThere is another way to print everything in a list out on one line without saving the words in the list in a new variable. We can use end = ' ' at the end of a print statement and that will ensure that a new line is not started:<jupyter_code>colors = ['red', 'blue', 'green']
for color in colors:
    print(color, end = ' ')<jupyter_output>red blue green<jupyter_text>Note that technically, there will be one extra space at the end of the line, but as long as you don't care, this is an easy way to print multiple things on the same line.  A third way to print things on the same lineWe can also use the join command. If we want to join each word with a space between them, we'll type:<jupyter_code>colors = ['red', 'blue', 'green']
print(' '.join(colors))<jupyter_output>red blue green<jupyter_text>In fact, if we wanted to insert "!!!" between each color, we could also use the join command:<jupyter_code>colors = ['red', 'blue', 'green']
print('!!!'.join(colors))<jupyter_output>red!!!blue!!!green<jupyter_text>Suppose I wanted to take those same colors and print out "Red is a color. Blue is a color. Green is a color." I could start with an empty sentence and add to it a new sentence for each time through the loop:<jupyter_code>colors = ['red', 'blue', 'green']
sentence = ''
for color in colors:
    sentence = ' '.join([sentence, color.title(), 'is a color.'])
print(sentence)<jupyter_output>Red is a color. Blue is a color. Green is a color.<jupyter_text>Notice that the print statement needed to not be indented. Otherwise, too many things would have gotten printed out:<jupyter_code>colors = ['red', 'blue', 'green']
sentence = ''
for color in colors:
    sentence = ' '.join([sentence, color.title(), 'is a color.'])
    print(sentence)<jupyter_output>Red is a color.
 Red is a color. Blue is a color.
 Red is a color. Blue is a color. Green is a color.<jupyter_text>Exercise - dogs 1Create a list of 5 dogs. Print out all of the dogs on one line, separated by a space, by creating an empty string and updating it in a loop. Get rid of the extra space at the end. DON'T use the join command or the end = ' ' command.<jupyter_code>#insert dogs<jupyter_output><empty_output><jupyter_text>Exercise - dogs 2Create a list of 5 dogs. Print out all of the dogs on one line, separated by a space, using the end = '' command.<jupyter_code>#insert dogs2<jupyter_output><empty_output><jupyter_text>Exercise - dogs 3Create a list of 5 dogs. Print out all of the dogs on one line, separated by a space, using the .join command<jupyter_code>#insert dogs 3<jupyter_output><empty_output><jupyter_text>Exercise - I like 1Write a program that takes in a list of names and prints out 'I like __'. For example, if you take in the list "<NAME>," it should print out on one line "I like Joe. I like Jack. I like Sue." You should start with an empty phrase and update it without using the join command.<jupyter_code>#insert i like #1<jupyter_output><empty_output><jupyter_text>Exercise - I like 2Write a program that takes in a list of names and prints out 'I like __'. For example, if you take in the list "<NAME>," it should print out on one line "I like Joe. I like Jack. I like Sue." Use the join command. This is a bit tricky!<jupyter_code>#insert i like 2<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08776693586531892, 'fraction_numerical': 0.008899322039836729, 'mean_word_length': 5.242782152230971, 'pattern_counts': {'":': 1, '<': 409, '<?xml version=': 0, '>': 409, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 5, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '121', 'dir': 'jupyter-structured-clean-dedup', 'id': '327535', 'license': 'MIT', 'n_tokens_mistral': 17448, 'n_tokens_neox': 16744, 'n_words': 7820, 'path': 'Python/Unit_1_Assignment.ipynb', 'repo_name': 'TheBlueness/2019-2020-HL-I-Comp-Sci', 'size': '57229'}