# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3 (ipykernel)
#     language: python
#     name: python3
# ---

# # Libraries

import re

# # Load article
#
# Download the text from [**here**](https://drive.google.com/file/d/1PEUMaDaPye5pxlA-SZTsnZ4k7WSzdLLe/view?usp=sharing) and load it into python using the following code snippet.

# Load lines into list
with open("Article.txt", encoding='utf-8') as f:
    lines = f.readlines()

lines+=list(lines) # list of lines

lines_list = []
for line in lines:
    if len(line) > 1:
        lines_list.append(line)



# # Tasks

# ### Print the first 20 lines of article

# + tags=[]
lines_list[:20]
# -



# ## Print out every line from the file that...

# ... that has 'q'

for line in lines_list:
    if re.findall(r"q", line):
                  print(line)

# ... that starts with 'H'

for line in lines_list:
    if re.findall(r"^H", line):
                  print(line)

# ... that has 'wh'

for line in lines_list:
    if re.findall(r"wh", line):
                  print(line)

# ... that has an 'q' or a 'Q'

for line in lines_list:
    if re.findall(r"q|Q", line):
                  print(line)

# ... that has a '*' in it

for line in lines_list:
    if re.findall(r"\*", line):
                  print(line)

# ... that has a '*' (star) in it

# +
#
# -

# ... that starts with an 'T' or an 't'

for line in lines_list:
    if re.findall(r"T|t", line):
                  print(line)

# ... that starts with number

for line in lines_list:
    if re.findall(r"^\d", line):
                  print(line)

# ... that has both 'a' and 'e'  and 'i' and 'o' and 'u' in it

# +
#
# -

# ... that has an 'a' and somewhere later an 'e'

# +
#
# -

# ... that does not have an 'i'

for line in lines_list:
    if not re.findall(r"i", line):
                  print(line)

# ... that does not have an 'i' nor 'z'

for line in lines_list:
    if not re.findall(r"i|z", line):
                  print(line)

# ... that has an 'x' but not 'y'

for line in lines_list:
    if re.findall(r"(?!x)(y)", line):
                  print(line)

# ... that has at least 2 consecutive vowels (a, e, i, o, u) like in the word "bear"

# +
#
# -

# ... that has at least 3 vowels

# +
#
# -

# ... that has at least 30 characters

# +
#
# -

# ... has the same word appear twice in the same line

# +
#
# -

# ## Print all the words

# Words with either 'Bar' or 'Baz' in them

# +
#
# -

# Words with either 'Whe' or 'The' in them

# +
#
# -

# Words containing a double character (e.g. 'oo')

# +
#
# -

# ## Cleanup string codes so they contain only numbers
# * Remove slash and spaces

# +
codes = ['2373/ 8293', 
         ' 8292342 / 8263', 
         '12/903820 ',
         '8203184 / 02342 ']

#
# -

# ## Switch order of the numbers in string
# * Preserve slash /
# * Remove spaces

# +
codes = ['2373/ 8293', 
         ' 8292342 / 8263', 
         '12/903820 ',
         '8203184 / 02342 ']

#

StarcoderdataJupyterScriptsDedupFiltered