Beginner Ord Print and Table Format Question

Viewed 21

I have to write a code that produces the following:

Letter Code
  A     65
  B     66
  C     67
  D     68
  E     69

...

  Z     90

I have this written but it isn't working:

test_str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
print("Letter " + " Code")
for chr in test_str:
  print(chr)
for ord in test_str:
  print(ord)

I can't get the ord Unicode to print and I don't know how to format so the letters and code end up in table format.

Any help for this beginner would be appreciated.

1 Answers

Try this

test_str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
print("Letter " + " Code")
for chr in test_str:
     print(chr,ord(chr))
Related