str_user = input('Enter your string: ')
# ord('A') = 65 ord('Z') =90
print (*[ord(i.upper())-64 for i in str_user if 65<= ord(i.upper()) <= 90],sep='-')
if we give space between two words it is printing "-"
if we give "sudheer kumar" it should print 19-21-4-8-5-5-18 11-21-13-1-18 like this.
but it is printing like this 19-21-4-8-5-5-18-11-21-13-1-18 with no space
str_user = input('Enter your string: ')
for i in str_user:
n=ord(i.upper())
if 65<= n <= 90:
print(n-64,end="-")
if i==" ":
print(" ",end="")
Comments
Leave a comment