How To Change Character To ASCII In Python Without Ord()
I know the function 'ord' can convert character to number. but I just want to know how to convert without 'ord' C can convert it, but is it impossible in Python ?
Solution 1:
You can encode a string as bytes, at which point you can access the representation of each character. So you can do this:
print("a".encode()[0])
print("3".encode()[0])
print("#".encode()[0])
Result:
97
51
35
Solution 2:
You can use len() function to solve it
input("any value?")
print(len("value"))input("any value you want") print(len("enter your value"))
Post a Comment for "How To Change Character To ASCII In Python Without Ord()"