๐ฑ Learning Go and PostGIS.
๐ Feel free to reach out.
kylejb / py4e-student-repo Goto Github PK
View Code? Open in Web Editor NEWUniversity of Michigan's Python for Everybody ("py4e") Specialization | Completed 01/2020
University of Michigan's Python for Everybody ("py4e") Specialization | Completed 01/2020
https://github.com/kylejb/py4e-student-repo/blob/master/2_Python-Data-Structures/ch_09/ex_09_04.py [updated url -kylejb]
Think about what you wrote and lets walk through it
words = line.split()
First off, what is line? It's undefined at this block, but let's write the code I think you had that's breaking.
for line in handle:
words = line.split()
for word in words:
# Parameter to focus only on lines starting with "From "
if line.startswith("From "):
email = words[1]
print(email)
counts[email] = counts.get(email, 0) + 1
Ok, let's stub some data
line = "From [email protected] on Dec 13 2019"
words = ["From", "[email protected]", "on", "Dec", "13", "2019"]
Now you run for word in words
, which is 6 iterations of your loop. That means 6 times you run this code
if line.startswith("From "):
email = words[1]
print(email)
counts[email] = counts.get(email, 0) + 1
For the exact same line. Before you even get to line 2 in the file, you've added my email 6 times because you're checking for every word. You just want to check each line in the file.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.