关于列表中元素
n = input().split(',')time = 0
youranswer = []
while time !=len(n):
a = n
b = a[-1]
youranswer.append(b)
time +=1
print('Your answer:',*youranswer)
比如 输入:1456A, 7896A, 0000E, 7777A
结果是:Your answer: A A E A
请问该怎么消掉元素之间的空格变成AAEA? >>> import re
>>> s="1456A, 7896A, 0000E, 7777A"
>>> re.sub("\d+|,| ","",s)
'AAEA'
>>> 最后一句改成print('Your answer:',*youranswer, sep="")就行
页:
[1]