user9803735
user9803735

Reputation:

python Print String uppercase only

I'd like to get a string and print it by separating the lowercase character classification.

s = list()
s = input('input : ')

and i wanna recognize, and remove lowercase.

Upvotes: 1

Views: 89

Answers (2)

BernardL
BernardL

Reputation: 5434

Use the inbuilt string functions which inludes .isupper and .islower then join them accordingly if you want to.

inp = input()

up = ''.join(i for i in inp if i.isupper())
low = ''.join(i for i in inp if i.islower())

print('upper: {} \nlower:{} '.format(up,low))

BSDSsdsdSD
upper: BSDSSD 
lower:sdsd 

Upvotes: 2

Red Cricket
Red Cricket

Reputation: 10470

Use a regex like so:

import re
l = input('input :')
print(re.sub('[a-z]','',l))

Upvotes: 1

Related Questions