PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, August 11, 2022

[FIXED] How to print an ascii table in python?

 August 11, 2022     ascii, decimal, hex, python     No comments   

Issue

I have a problem. I want to print a part of ASCII-Table. I mean it like this: I give first number - for Example 40 - and last number - let's say 100 and it print me number form 40 to 100. Including 40 and 100.
I got this so far:

def dectohex2(beg,end):
    print('{0:x}'.format(int(beg))," ", chr(beg))
    print('{0:x}'.format(int(end))," ", chr(end))

But I'm not sure what to put between those, to print other numbers.


Solution

Use a for loop over the range between beg and end+1:

def dectohex2(beg,end):
    for i in range(beg, end+1):
        print('{0:x}'.format(int(i))," ", chr(i))


Answered By - jh314
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing