1.2.3 Special Characters
Video
1.2.3 Special Characters
Python, like most other programming languages, has a set of special characters that you learn over time as a programmer. This video will show you several of them and how to use them, but this table contains a full list. Don't worry if some of their definitions are unfamiliar and feel free to experiment and see what they do!
Try It Yourself
The code editor below is pre-loaded with the special_characters.py file. This example shows three important special characters:
\'- Escape single quote (allows using single quotes inside single-quoted strings)\n- New line (creates a line break)\t- Tab (creates spacing for columns)
Steps to follow:
- Run the code - Click "Run" to see how each special character works
- Experiment - Try combining multiple special characters
- Create your own - Write a message using tabs and newlines to format it nicely
message = 'It\'s my birthday' # Escape the apostrophe print('Happy\nbirthday') # New line print('Happy\tbirthday') # Tab spacing
Note: The video shows creating a file in Spyder, but you're using the browser-based editor instead. The concepts are the same - you can edit code, run it, and see the output just like in the video!
Loading Python environment...