a=1
l1=''
l2=''
while a!='e':
a=input()
if a>='a' and a<='z':
l2+=a
if a>='A' and a<='Z':
l1+=a
print('大写字母为',end='')
print(l1)
print('小写字母为',end='')
print(l2)
代码如下:
while True:
_input = input("请输入任意字母,以'e'结束:\n")
if len(_input) >0 and _input[-1] == "e":
break
else:
print("输入字母没有以e结尾,请重新输入")
low_list = []
up_list = []
for i in _input:
if i.islower():
low_list.append(i)
continue
if i.isupper():
up_list.append(i)
print("大写字母为:", "".join(up_list))
print("小写字母为:", "".join(low_list))
输出为:
请输入任意字母,以'e'结束:
MaTLabe
大写字母为: MTL
小写字母为: aabe
如有问题及时沟通
【有帮助请采纳】
s = input()
daxie = ''
xiaoxie = ''
for i in s:
if 65<=ord(i)<=90:
daxie += i
else:
xiaoxie += i
print('大写字母为:%s'%daxie)
print('小写字母为:%s'%xiaoxie)
【有帮助请采纳】
s = input()
d = ''
x= ''
for i in s:
if 65 <= ord(i) <= 90:
d += i
else:
x += i
print('大写字母为:%s' % d)
print('小写字母为:%s' % x)
import string
text = input('键盘输入: ')
print('大写字母为:', ''.join([c for c in text if c.isupper()]))
print('小写字母为:', ''.join([c for c in text if c.islower()]))
题目有没有问题,我的理解是字母一个一个输入的。后半句“并进行大小写转换” 转换什么哪里的没说明白
s,t1,t2 = '','',''
while s!="e":
s = input()
if len(s)>1:
print('每次只输入一个字母,请重输:')
continue
if s.isupper():
t1 += s
elif s.islower():
t2 += s
else:
print('输入的不是字母,请重输:')
print('大写字母为:%s'%t1)
print('小写字母为:%s'%t2)