dynamic variable in python code example
Example 1: creating dynamic variable in python
for i in range(0, 9):
globals()[f"my_variable{i}"] = f"Hello from variable number {i}!"
print(my_variable3)
# Hello from variable number 3!
Example 2: python dynamic variable name
name = "a"
value = True
a_dictionary = {name: value}
print(a_dictionary["a"])
Example 3: creating dynamic variable in python
for i in range(0, 9):