Skip to content
Sign upLog in
This post is read-only. Explore Repls and connect with other creators on Community.View Community
The info in this post might be out of date, check out our docs instead. View docs

How to make an input create a variable


I want to be able to create new variables without having to go into the code is there any way to do this

3 years ago
You are viewing a single comment. View All

If you are using Python like mentioned in the comments, you can use a dictionary to do this. To create the variables, you can use a function like:

# To store all of your variables allvars = {} # Adds a variable name and value of each variable def addvar(name, val): allvars[name] = val

You can then access your variables from the dictionary, like so:

# Loop through all the keys and valuses in the dictionary for name, val in allvars.items(): # Print the name fo the variable and it's value print(f"{name}:{val}")

Hope this is what you were looking for.

3 years ago