ASCII | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

ASCII

In python - If user inputs a alphabet and I want to store its ascii value in a variable how can I do this?

26th May 2018, 6:15 AM
Diwakar Jain
Diwakar Jain - avatar
4 Answers
+ 10
@Pegasus beat me to it. :) I was going to say I'm not exactly sure what you mean by input an alphabet, but these two built-in Python functions may be helpful: ord() returns the ASCII value of a character chr() returns the character for an ASCII value e.g.: print(ord("A")) # outputs 63 print(chr(65)) # outputs A
26th May 2018, 6:27 AM
David Ashton
David Ashton - avatar
+ 8
Use the ord(string) function
26th May 2018, 6:21 AM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
thanks lot
26th May 2018, 6:24 AM
Diwakar Jain
Diwakar Jain - avatar
+ 2
ord()
26th May 2018, 8:28 AM
Gummadi Nishna
Gummadi Nishna - avatar