Ask coding questions

← Back to all posts
How to make an input create a variable
Ferris

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

Voters
Stifftoenail
SimonGhebretens
SaadiqahKhan
Cheeri
SamanthaLeighL1
JahmalSpence
proggramming
pLimbakc
AyaanaSrinivasa
Comments
hotnewtop
LeonDoesCode

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:

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

Hope this is what you were looking for.

Giothecoder

Hey guys, isn’t there some weird scoping with var in js that would allow something like this?

AlexanderBirabe

Considering your profile says you code in python, I think you're looking for:

The variable 'variableName' gets set to a string of what the user types in (they have to hit enter to submit). You can replace 'prompt' with whatever you want the input prompt to be.

theangryepicbanana

What language are you using?

Giothecoder

Show us an example, please. I don’t think it is but, just try and show us an example first.