how to define unusual inputs? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how to define unusual inputs?

i want to make it so when my code sees !=26 @=27 #=28 *=29 (=30 )=31 -=32 ==33 +=34 ,=35 .=36 ?=37 it will treat them like variables

28th Mar 2020, 12:33 AM
Steven
Steven - avatar
6 Answers
+ 4
You can't do that, because there are rules for how variables can be made up and how not. What you can do: Create a dictionary and use them as pseudo variables. d = {} d['*'] = 42 d['<'] = 9 etc.
28th Mar 2020, 12:40 AM
HonFu
HonFu - avatar
+ 3
What I mean is: Instead of variable names, you access string keys in a dictionary. Since strings can be anything, you're not limited like you would be with variables.
28th Mar 2020, 12:51 AM
HonFu
HonFu - avatar
+ 2
Do you mean you want to assign to symbols? Like instead of... x = 42 ... you'd for example write... < = 42 ?
28th Mar 2020, 12:37 AM
HonFu
HonFu - avatar
+ 1
Make a dict like this dict = { "1":"one"}
29th Mar 2020, 12:26 PM
Wade
Wade - avatar
0
exactly
28th Mar 2020, 12:38 AM
Steven
Steven - avatar
0
what's the difference between variables and pseudo variables?
28th Mar 2020, 12:48 AM
Steven
Steven - avatar