{"id":17601,"date":"2021-08-26T10:42:38","date_gmt":"2021-08-26T05:12:38","guid":{"rendered":"https:\/\/python-programs.com\/?p=17601"},"modified":"2021-11-22T18:37:12","modified_gmt":"2021-11-22T13:07:12","slug":"python-program-to-convert-each-character-in-a-string-to-an-ascii-value","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-convert-each-character-in-a-string-to-an-ascii-value\/","title":{"rendered":"Python Program to Convert each Character in a String to an ASCII Value"},"content":{"rendered":"

In the previous article, we have discussed Python Program to Divide a String in ‘N’ Equal Parts.<\/a>
\nWhen each character in a string is converted to an ASCII value, a list of corresponding ASCII values for each character is returned. Converting each character in “dce” to an ASCII value, for example, yields [100, 99, 101].<\/p>\n

Given a string and the task is to convert each character in a given String to an ASCII Value.<\/p>\n

ASCII Characters:<\/strong><\/p>\n

The standard range of ASCII, which stands for American Standard Code for Information Interchange, is \u201cZero\u201d to \u201cOne Hundred and Twenty Seven\u201d.<\/p>\n

ASCII codes are used to represent text in computers and other electronic devices. The character-encoding schemes used in most modern telecommunications equipment are based on ASCII.<\/p>\n

As a result, everything else falls into the category of \u201cnon-ASCII\u201d character.<\/p>\n

ord() function:<\/strong> To determine the specific ASCII value of that character.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given String = \" btechgeeks\"<\/pre>\n

Output:<\/strong><\/p>\n

The given string after convering each character to an ASCII value : [98, 116, 101, 99, 104, 103, 101, 101, 107, 115]<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

Given String = \"hello this is btechgeeks\"<\/pre>\n

Output:<\/strong><\/p>\n

The given string after convering each character to an ASCII value : [104, 101, 108, 108, 111, 32, 116, 104, 105, 115, 32, 105, 115, 32, 98, 116, 101, 99, 104, 103, 101, 101, 107, 115]<\/pre>\n

Program to Convert each Character in a String to an ASCII Value.<\/h2>\n

Below are the ways to convert each character in a given String to an ASCII Value.<\/p>\n