Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Python Program To Display Characters From A to Z

Problem Definition Create a Python Program to display all alphabets from A to Z. Solution This article will go through two pythonic ways to generate alphabets. Using String module Python’s built-in string module comes with a number of useful string functions one of them is string.ascii_lowercase Program Import String for i in string.ascii_lowercase: print(i, end=" ") Output a b c d e f g h i j k l m n o p q r s t u v w x y z The string.ascii_lowercase method returns all lowercase alphabets as a single string abcdefghijklmnopqrstuvwxyzso the program is simply running a for loop over the string characters and printing them. Similarly for uppercase A to Z letters. Program import string for i in string.ascii_uppercase: print(i, end=" ") Output A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Using chr() Function The chr() function in Python returns a Unicode character for the provided ASCII value, hence chr(97) returns “a”. To learn more about chr() …

The post Python Program To Display Characters From A to Z appeared first on Django Central.



This post first appeared on Django Central, please read the originial post: here

Share the post

Python Program To Display Characters From A to Z

×

Subscribe to Django Central

Get updates delivered right to your inbox!

Thank you for your subscription

×