A variable is created the moment you first assign a value to it.
Variables do not need to be declared with any particular type, and can even change type after they have been set.
If you want to specify the data type of a variable, this can be done with casting.
You can get the data type of a variable with the type() function.
String variables can be declared either by using single or double quotes:
Variable names are case-sensitive.
This will create two variables:
a = 4W3schools Pathfinder Track your progress - it's free!
If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com
If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.