


However, there are still significant differences between the two data structures: In the accepted answer to this question on Stack Overflow people say that a List with Names is as close as you can get. Note that R does not really have an equivalent data structure. As a rule of thumb, Python programmers prefer to define data structures with symbols instead of keywords. We can store this information in a Python Dict like this: > letter_scores =. For example, each Scrabble letter can be viewed as a key, and its numeric score can be viewed as its value. Dictionariesĭictionaries (often just called Dicts) define a key-value relationship. The main Built-in Data Structures that I used in this project are Dictionaries, Lists and Tuples. In fact, when talking to my friends who teach Python, they emphasized that expertise in Python often comes down to having fluency with the Built-ins. But unlike R, it appears that people are generally happy with Python’s Built-ins, and do not recreate that functionality in other packages.
SCRABBLE CHEAT MAIN FULL
(You can see the full list of Python’s Built-ins here). Python’s equivalent of “Base R” is called “Built-ins”. This split between “functionality that ships with R” and “how people ‘in the know’ actually use R” is inherently confusing. Similarly, the graphics package has a plot function for making graphs, but the ggplot function in the ggplot2 package is much more popular. But the read_csv function from the package readr is actually faster and does not automatically convert strings to factors, which is often desirable. For example, the utils package has a function read.csv for reading CSV files. One of the more confusing things about R is that people are increasingly moving away from Base R to 3rd party libraries for routine tasks. “Base R” also colloquially refers to “all the packages that ship with R and are available when you load it” such as utils, graphics and datasets. Base R, while itself a package, cannot be uninstalled, and contains core language elements like ame and vector.

One of the central concepts in R is the distinction between “Base R” and “Packages you choose to install”. “what is a list of tuples, and why is the data structured this way?”) But first, it’s useful to do a compare-and-contrast between Base R and Python Builtins. This post will help you make sense of this output (i.e. The list is ordered so that the highest-scoring word appears first: > get_all_words('ilzsiwl') It returns a list of tuples that represent valid words you can form from those letters, along with their score in Scrabble. The key function is get_all_words, which takes a string that represents a set of tiles. You can view the “Scrabble Cheat” project on github here. Additionally, most data-related jobs in Industry (as opposed to Academia) use Python rather than R. However, over time I’ve learned that many of my readers are also interested in Python. Most people read my blog because of Choroplethr (my suite of R packages for mapping open datasets) or my various R trainings. I just wrapped up this project and decided to share it because it might help others who are interested in Python. Voila – my first Python side project was born! Eventually I realized that it would be straightfrorward to write a program in Python that looked at my rack of letters and listed the highest scoring word I could create. The problem is that I hate the game, and not good at it, and kept on losing. In order to pass the time my mother (a retired English teacher) became obsessed with Scrabble and insisted on playing game after game with me.

This all changed during the COVID-19 lockdowns. While I was interested in having a side project in Python for a while, it took me a while to find a project that interested me. Side projects are great for learning a language because they let you “own” a project from start to finish as well as solve a problem that is of genuine interest to you. After taking a few online courses, I became comfortable enough with the language to tackle a small side project. My New Year’s Resolution was to learn Python.
