By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,908 Members | 1,945 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,908 IT Pros & Developers. It's quick & easy.

How do I get the ASCII values for a word

P: n/a
In my program, I have to get 2 letter from the first name. How do I get the asc values for those 2 letters.
*the letters change every time so I can't just use... for ex. ja
ord('j')
ord('a')
how would i get values for any of the letters no matter what they are??
Oct 31 '10 #1
Share this Question
Share on Google+
1 Reply


Expert 100+
P: 624
You would pass each of the first two letters to ord. From your example, there is no way to tell anything more, but generally speaking it is simpler to work with lists instead of strings.
Expand|Select|Wrap|Line Numbers
  1. first_letter = "A"
  2. second_letter = "b"
  3. print first_letter, ord(first_letter), second_letter, ord(second_letter) 
Oct 31 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.