read.cash Log in
@MyHero

Program 101: Ascending and Descending String using Python This program sort and display the input string into ascending and descending orders. Note: A string consists of characters like letters, numbers and and special characters Running Program: https://onlinegdb.com/7aGNa21oZ Code: # Ascending and Descending String using Python chk = input ("Enter a string/word only: ") asc = sorted(chk) asc = ''.join(asc) desc = sorted(chk, reverse=True) desc = ''.join(desc) print("\n----- Result -----") print("String Ascending Order:", asc) print("String Descending Order:", desc)

4 comments

Log in to join in Reading is open to everyone. Replying needs an account.