149|PYTHON – The Mysterious Mascot

BYU Student Author: @Millie_K_B
Reviewers: @Kyle_Nilsen, @Trent_Barlow
Estimated Time to Solve: 30 Minutes

This is an intro challenge that is part of the Python Learning Path.

We provide the solution to this challenge using:

  • Python

Need a program? Click here.

While scrolling through your social media feed, you come across a compelling, artistic, energetic, viral video of a cougar mascot dancing with a cheer team. (If you’re curious, you can find the video we’re referencing here).

Intrigued, you decide to investigate further, and learn from the caption that the mascot is none other than Cosmo the Cougar! Unfortunately, at that very moment, you must return to your homework investigating Python packages.

Undeterred, you decide to see if Python has any packages that could assist in your research on this mysterious, compelling Cosmo. You’re interested in discovering what university he is from and where that university is located. Then you can quickly transfer your records there, because clearly that school is a fun and exciting place to be!


  1. Open a new Jupyter workbook and import the following packages using pip install:
  2. Using Ao, pull the articles you think will help you determine where Cosmo’s university is located.
  3. Using RegEx (and any other tools you’ve learned so far), create a string variable containing the location of Cosmo’s university.
  4. Print the string variable.

NOTE: Your code does not need to have a prettily formatted output or be extremely efficient to start. The purpose of this challenge is to practice downloading new packages and trying new things in Python. The solution code will provide one example of how to print the location of Cosmo’s university, but we encourage you to spend some time experimenting with these packages, finding alternative ways to code, and increasing your efficiency.

Suggestions and Hints

Always refer back to the package’s project description for help determining how it is best utilized.

For RegEx help, use this link to RegExOne as a reference and for practice writing regular expressions. Or, for more detailed information about RegEx specific to Python’s RegEx package, go here.

This is an example of what a pip install of Ao will look like, for guidance:


This was a fun little challenge, and showed off a lot about the versatility of all the libraries! Below find my solution code. I used ao to pull out the entries I needed. After printing the whole entry, I determined how to find the snippet I needed using regex, and wrote an expression to capture the texts I wanted as “university” for the name of the university and “location” as the city. I also noted ao returned BYU if you input “byu” or “brigham_young_university.” Below is my code:

import regex
from ao import cosmo_the_cougar
from ao import byu as thing

# find all characters before the first "("
match = regex.search(r'(^(.*?)\))', thing)

if match:
    university = match.group(1).strip()
    university = ""

#Find Provo and everything up until the next period
match = regex.search(r'(Provo[^.]*\.)', thing)

if match:
    location = match.group(1)
    location = ""

print(f"Cosmo the Cougar's university is {university} and it is located in {location}")