0
Letter as number
How could I make it so a letter is equal to a number but no number? I want to make it so in my code x is a number but the number isnāt specified that way it could be any number
7 Answers
+ 2
Are you talking about declaring a variable without assigning a value? I don't think that's possible in python.
https://david.goodger.org/projects/pycon/2007/idiomatic/handout.html#other-languages-have-variables
0
# The str() function converts the specified value into a string.
print(str(9)*3)
print(9*3)
0
Python Built-in Methods
https://www.tutorialsteacher.com/python/builtin-methods
0
You could reference the number within a dictionary using get().
say i have a dictionary:
a = {'a': 1, 'b': 2, ....}
and i want a letter i get to change to whatever number should represent it, i took the simple approach.
Anytime you get a letter you want only to be associated with it's number, send it through the dictionary.
char = 'g'
lett_as_num = a.get(char, None)
0
Simon Sauter yes
0
Slick however thats assigned number
0
exonits perhaps you are interested in the field of Fuzzy Logic, where variables may represent a range of values.
https://en.m.wikipedia.org/wiki/Fuzzy_logic
https://towardsdatascience.com/fuzzy-inference-system-implementation-in-JUMP_LINK__&&__python__&&__JUMP_LINK-8af88d1f0a6e?gi=3d1c3f8a0ee1
https://pythonhosted.org/scikit-fuzzy/overview.html