How about using upper()
?
>>> s = "apple"
>>> s[:4]
'appl'
>>> s[:4].upper()
'APPL'
Speaking about the code you've written, you can modify it this way to make it work:
def capital(uinput):
slice4 = uinput[:4]
result = ""
for i in slice4:
j = ord(i)
j = j - 32
k = chr(j)
result += k
print result
or, the same but in one line without having additional variables:
def capital(uinput):
print "".join([chr(ord(i) - 32) for i in uinput[:4]])