mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-06-22 21:08:12 +08:00
fix(curriculum): add brief explanation of strings (#62495)
Co-authored-by: Huyen Nguyen <25715018+huyenltnguyen@users.noreply.github.com> Co-authored-by: Ilenia <26656284+ilenia-magoni@users.noreply.github.com>
This commit is contained in:
parent
a389bc7364
commit
3176f36bd2
@ -16,13 +16,14 @@ name = 'John Doe'
|
||||
age = 25
|
||||
```
|
||||
|
||||
In the example above, the variable `name` holds the value `'John Doe'`. This value is a string, which is a series of characters used to represent text. Strings are written with single or double quotes, for example `'Hello'` or `"Hello"`. In future lessons, you'll learn more about working with strings in Python.
|
||||
|
||||
When naming variables in Python, there are some important rules you should keep in mind:
|
||||
|
||||
- Variable names can only start with a letter or an underscore (`_`), not a number.
|
||||
- Variable names can only contain alphanumeric characters (`a-z`, `A-Z`, `0-9`) and underscores (`_`).
|
||||
- Variable names can only start with a letter or an underscore (`_`), not a number.
|
||||
- Variable names can only contain alphanumeric characters (`a-z`, `A-Z`, `0-9`) and underscores (`_`).
|
||||
- Variable names are case-sensitive — `age`, `Age`, and `AGE` are all considered unique.
|
||||
- Variable names cannot be one of Python's reserved keywords such as `if`, `class`, or `def`.
|
||||
|
||||
|
||||
If you break any of those rules, your Python program will throw a `SyntaxError`:
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user