CodeNewbie Community

loading...

How do I create a variable in Python?

natqueencole profile image Natalie ・1 min read

Hi all! I'm working on learning a little Python, but it's syntax is throwing me - I come from more a JS background.

How do I create a variable in Python?

Thanks!

Discussion (3)

Collapse
kaitheceo profile image
Kai Lyons

Hello! Wonderful question!

The simple syntax for a variable is:
variable_name = value

EXAMPLES:
name = "Kai"
is_true = True
zero = 0

Hope this helps!

Collapse
bandeirademelo profile image
Bandeira

One of the coolest things about python is how simples it's syntax is:

name_of_variable = value

cat = "Jack"

Collapse
preshh0 profile image
Your .py Princess!

You just use:

variable_name = 'Name', for strings
variable_name = 1, for numbers. Those one don't carry quotes.

Forem Open with the Forem app