python declare multiple variables code example

Example 1: declare multiple variables at once python

a = b = c = "Hello, World"
print(a)
print(b)
print(c)
# OUTPUT:
# Hello, World
# Hello, World
# Hello, World

b = "foo"
c = "bar"
print(a)
print(b)
print(c)
# OUTPUT:
# Hello, World
# foo
# bar

Example 2: assign multiple variablesin one line

#Instead Of
a = 1
b = ('Hello")

#You Can Do
a,b = 1,'Hello'

Example 3: assign three variables in python in one line

var1, var2, var3 = 1, 'superman',3.7

Example 4: multiple variable declaration in python

a, b, c = 0.1, 100, 'string'

print(a)
# 0.1

print(b)
# 100

print(c)
# string