[Tutor] ASCII characters
Kent Johnson
kent37 at tds.net
Tue May 24 19:46:36 CEST 2005
John Carmona wrote:
> Thanks Kent for the reply, I am actually having trouble to find the
> solution of the following exercise:
>
> ## Write a for loop that prints the ASCII code of each character in a
> string name S.##
>
> I am ok with the for loop, put I don't know how get to print the ASCII
> code of each character with a string (I also know how to use the String).
You need the ord() function and maybe hex() also:
>>> ord('s')
115
>>> hex(ord('s'))
'0x73'
Kent
More information about the Tutor
mailing list