I want get ansii code for my random symbol, but I don't know how to get him.
I made symbol generator:
import random
string = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
def random_string(count: int):
result = ""
for i in range(count):
if random.randint(0, 1):
result += random.choice(string).upper()
else: result += random.choice(string)
return result
I generate string with length 1 and want get him ansii code. How can I make this?
You can use ord() function for you targets. Example:
print(ord(random_string(1))