Wednesday, February 8, 2017

Practice 2 - Pythonicness and Packaging

Pythonicness and Packaging

The coolest thing I learned as part of the the Pythonicness and Packaging module on SoloLearn was a concept called "tuple unpacking." When I learned about unpacking tuples I wanted to write some code that would allow me to unpack a list of emails that I hypothetically scraped from a file. 

Email Unpacking Code:

emails = ("student@school.edu", "person@email.com", "dino@meteor.gov")
count = 0
for i in emails:
    email = i
    count += 1
    strgcount = str(count)
    word = "Email # " + strgcount + " is: "

    print(word + email)

Score
10/10

No comments:

Post a Comment