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

1st Dec 2021, 12:52 AM
ŠµŠŗсŠæŠ¾Š½ŠµŠ½Ń‚Šø
ŠµŠŗсŠæŠ¾Š½ŠµŠ½Ń‚Šø - avatar
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
1st Dec 2021, 1:38 AM
Simon Sauter
Simon Sauter - avatar
0
# The str() function converts the specified value into a string. print(str(9)*3) print(9*3)
1st Dec 2021, 1:28 AM
SoloProg
SoloProg - avatar
1st Dec 2021, 1:46 AM
SoloProg
SoloProg - avatar
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)
1st Dec 2021, 1:50 AM
Slick
Slick - avatar
1st Dec 2021, 12:48 PM
ŠµŠŗсŠæŠ¾Š½ŠµŠ½Ń‚Šø
ŠµŠŗсŠæŠ¾Š½ŠµŠ½Ń‚Šø - avatar
0
Slick however thats assigned number
1st Dec 2021, 12:49 PM
ŠµŠŗсŠæŠ¾Š½ŠµŠ½Ń‚Šø
ŠµŠŗсŠæŠ¾Š½ŠµŠ½Ń‚Šø - avatar