Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Elizabeth McInerney
Elizabeth McInerney
3,175 Points

Workspaces and Forum - I am new and having trouble with these features

I am new and in the beginner Python course, and am having 2 problems.

1) I ran into a problem with one of the challenge assignments. So I set up a Workspace to test my code with print statements there, and cannot get it to execute. I put my code in a file called test.py. When I run test.py, I do not get anything printed out, despite the fact that my code in test.py contains print statements.

2) Then I went to the Forum, to get help there, and find that my code disappears when I return to my assignment. Is there a way to retain my code?

Any advice would be appreciated!

2 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,423 Points

Hi Elizabeth,

When running in a workspace, are you doing the folowing:

  • placing your code in a file, such as test.py,
  • saving the file in the workspace,
  • in console window below the file editor, typing python test.py

If your print statement is within a function, but the function is not run, nothing will print out. Try adding:

print("Hello, World!")

as the last or first line of your test.py file and rerunning it. If you are trying to execute a function be sure to have a call to that function within the test file:

data = "some string"
myfunctions(data)

One downside to the code challenges is your code is not saved if the page is reload. To save your code you will need to copy and paste it to a workspace or another file on your computer.

Elizabeth McInerney
Elizabeth McInerney
3,175 Points

Thanks, I was not saving my file after I added lines of code. I do not recall seeing the instructor saving when he created .py files, but I will have to check for this in future videos.

Elizabeth McInerney
Elizabeth McInerney
3,175 Points

I have everything working now. It helped a great deal switching to Google Chrome. My only problem now is that I cannot cut and paste unfortunately, so that makes it more difficult to move code around.

Chris Freeman
Chris Freeman
Treehouse Moderator 68,423 Points

Have you tried Control-x for cut, Control-c for copy, Control-v for paste?