rlvaugh / Impractical_Python_Projects

Code & supporting files for chapters in book
401 stars 269 forks source link

Simplify digram generation and sort #8

Open justducky opened 4 years ago

justducky commented 4 years ago

Simplify digram generation and sort Sort digram frequency count

rlvaugh commented 3 years ago

Thank you, I will update the next version of the book to include your changes. It is going into the 4th printing now so this will probably occur sometime in 2021.

rlvaugh commented 3 years ago

We are getting ready for the next printing and I noticed that your code is doubling the frequency count for digrams like "vo." It looks like you overwrite the digrams set with this line:

digrams = sorted([''.join(i) for i in permutations(name, 2)])

When you print out the list of digrams, you'll see that several are duplicated, which can't happen with a set data type. This is overall a good approach however, and I plan to include an edited version in the update.