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

Khadija Raffat
seal-mask
.a{fill-rule:evenodd;}techdegree
Khadija Raffat
Data Analysis Techdegree Student 348 Points

I made a new file in Pycharm but when I try to run the code, it runs the previous file. How do i switch to my new file?

I'm running codes on Pycharm but when I add a new file and then write the code and try to run it, it runs the previous file code. I can't seem to figure out how to run the new file.

Anybody know how to do it?

1 Answer

Kiefer H
Kiefer H
5,665 Points

Right Click in your Code -> Select 'Run'

PyCharm by default saves a config when you run a python script so it automatically gets selected you press Shift-F10 (or whatever your keybind is to run your scripts) or the Green Arrow.

To prevent this, you can select the drop-down next to the Green Arrow on the toolbar and select 'Current File' so it will ALWAYS run the file in the code preview.

Here is a preview: NOTE that the "Run 'Database'" the Database is my current Python script name.

https://imgur.com/a/6jdCUCv