Q:

Python program capitalize the character without using a function

belongs to collection: Python basic programs

0

Example:

    Input:
    Hello world!

    Output:
    HELLO WORLD!

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Python code to capitalize the character without using a function

# Python program to capitalize the character 
# without using a function
st = input('Type a string: ')
out = ''
for n in st:
    if n not in 'abcdefghijklmnopqrstuvwqxyz':
        out = out + n
    else:
        k = ord(n)
        l = k - 32
        out = out + chr(l)
print('------->', out)    

Output

First run:
Type a string: Hello world!
-------> HELLO WORLD!

Second run:
Type a string: 12345Hello @123$#
-------> 12345HELLO @123$#

Third run:
Type a string: 82918298198291898A
-------> 82918298198291898A

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python basic programs

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now
Python program to lowercase the character without ... >>
<< Python program to convert yards into meters...