weraol.blogg.se

Notepad++ python indentation error
Notepad++ python indentation error




notepad++ python indentation error

To do so, type the following line and then hit Enter: python first_script.py

notepad++ python indentation error

For example, on my computer, I’d type: cd "C:\Users\Clinton\Desktop"Īt this point, the prompt should look like C:\Users\\Desktop, and we are exactly where we need to be, as this is where we saved the Python script. Replace with your computer account name, which is usually your name. To do so, type the following line and then hit Enter: cd "C:\Users\\Desktop"

notepad++ python indentation error

Navigate to the Desktop (where we saved the Python script). When the window opens the prompt will be in a particular folder, also known as a directory (e.g., C:\Users\Clinton or C:\Users\Clinton\Documents). Running a Python script, first_script.py, in Anaconda SpyderĪlternatively, you can run the script in a Command Prompt (Windows) or Terminal window (macOS), as described next: Windows Command Prompt Figures 1-1, 1-2, and 1-3 show what it looks like in Anaconda Spyder, Notepad++ (Windows), and TextWrangler (macOS), respectively.įigure 1-4. However, in this case you want to save it as a. In the past, you’ve probably saved a text file as a. In the Save As box or File Name box, type “first_script.py”. In the format box, select All Files so that the dialog box doesn’t select a file type. In the location box, navigate to your Desktop so the file will be saved on your Desktop. This line will print the text between the double quotes to the Command Prompt (Windows) or a Terminal window (macOS). The second line is a simple print statement. Because Windows machines ignore this line and Unix-based systems such as macOS use it, including the line makes the script transferable among the different types of computers. However, Unix computers use the line to find the version of Python to use to execute the code in the file. The # precedes a single-line comment, so the line of code isn’t read or executed on a Windows computer. Notice that the first character is the pound or hash character ( #). The first line is a special line called the shebang, which you should always include as the very first line in your Python scripts. Write the following two lines of code in the text file: #!/usr/bin/env python3 print ( "Output #1: I'm excited to learn Python." ) Open the Spyder IDE or a text editor (e.g., Notepad, Notepad++, or Sublime Text on Windows TextMate, TextWrangler, or Sublime Text on macOS).






Notepad++ python indentation error