# Reference guide: Python concepts from module 4

## <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">File operations</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">The following functions, methods, and keywords are used with operations involving files.</span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">with</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Handles errors and manages external resources</span>

#### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open("logs.txt", "r") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Used to handle errors and manage external resources while opening a file; </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;">the variable </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">file</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> stores the file information while inside of the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> statement; </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">manages resources by closing the file after exiting the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> statement</span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">open()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Opens a file in Python</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open("login\_attempts.txt", "r") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;">Opens the file </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"login\_attempts.txt"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> in order to read it </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">("r")</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open("update\_log.txt", "w") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;">Opens the file </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"update\_log.txt"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> into the variable </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">file</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> in order to write over its contents </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">("w")</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open(import\_file, "a") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;">Opens the file assigned to the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">import\_file</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> variable into the variable </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">file</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> in order to append information to the end of it </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">("a")</span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">as</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Assigns a variable that references another object</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open("logs.txt", "r") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Assigns the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">file</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> variable to reference the output of the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">open()</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> function </span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">.read()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Converts files into strings; returns the content of an open file as a string by default</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open("login\_attempts.txt", "r") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;"> file\_text = file.read()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Converts the file object referenced in the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">file</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> variable into a string and then stores this string in the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">file\_text</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> variable</span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">.write()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Writes string data to a specified file</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">with open("access\_log.txt", "a") as file:</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;"> file.write("jrafael")</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Writes the string </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"jrafael"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> to the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"access\_log.txt"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> file; because the second argument in the call to the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">open()</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> function is </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"a"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">, this string is appended to the end of the file</span>

## <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 16pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Parsing</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">The following methods are useful when parsing data.</span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">.split()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Converts a string into a list; separates the string based on the character that is passed in as</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> an </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">argument; if an argument is not passed in, it will separate the string each time it encounters whitespace characters such as a space or return</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">approved\_users = "elarson,bmoreno,tshah".split(",")</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Converts the string </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"elarson,bmoreno,tshah"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> into the list </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">\["elarson","bmoreno","tshah"\]</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> by splitting the string into a separate list element at each occurrence of the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">","</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> character</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"><span class="Apple-tab-span" style="white-space: pre;"> </span></span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: transparent;"> </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">removed\_users = "wjaffrey jsoto abernard".split()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Converts the string </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"wjaffrey jsoto abernard"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> into the list </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">\["wjaffrey","jsoto","abernard"\]</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> by splitting the string into a separate list element at each space</span>

### <span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 14pt; font-family: 'Courier New', monospace; font-weight: bold; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #beb8b0; --darkreader-inline-bgcolor: #181a1b;">.join()</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Concatenates the elements of an iterable into a string; takes the iterable to be concatenated as an argument; is appended to a character that will separate each element once they are joined into a string </span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">approved\_users = ",".join(\["elarson", "bmoreno", "tshah"\])</span>

<span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;">Concatenates the elements of the list </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">\["elarson","bmoreno","tshah"\]</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> into the string </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">"elarson,bmoreno,tshah"</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> , separating each element with the </span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Courier New', monospace; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #212425;">","</span><span data-darkreader-inline-bgcolor="" data-darkreader-inline-color="" style="font-size: 12pt; font-family: 'Google Sans', sans-serif; font-weight: 400; font-style: normal; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; --darkreader-inline-color: #e8e6e3; --darkreader-inline-bgcolor: #181a1b;"> character within the string</span>