Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Introducing Dictionaries Introducing Dictionaries Update and Mutate Dictionaries

Son-Hai Nguyen
Son-Hai Nguyen
2,481 Points

How to copy the "course" into the interpreter?

How to How to copy the "course" into the interpreter, when you type "python3" into the Console?

Thanks guys

2 Answers

In the workspace, I'm not sure if there is a way to grab the text in the editor. The easiest way might be run python3, and then run "import dictionaries". This will load the program, and at that point you will have the courses variable set.

You may also be able to run "cat dictionaries.py", grab the text with your mouse, start python3, and then spit the text into the interpreter, however I'm not sure that works on all operating systems.

But in the end, there's nothing wrong with a little typing. :-)

Adrian's options work but to add to it, you can also type "python3 -i dictionaries.py" in the console which will run the dictionaries file and then allow you to interact with the file in the python console without having to explicitly import it. You can then access the course variable by referencing it by name instead of referencing the imported module first (e.g. dictionaries.course) as you would if you just typed "import dictionaries" directly into the python console. I tend to use "python3 -i ..." frequently and it works great for me so I figured I would add onto Adrian's answer.