python字符串连接大写字母

时间:2018-03-26 11:52:27

标签: sails.js

接受两个字符串' string1'和' string2'作为用户的输入。生成一个结果字符串,这样它就是两个字符串中出现的所有大写字母的串联字符串。在python中打印实际和结果字符串

1 个答案:

答案 0 :(得分:0)

string1 = input("Enter a string: ")
string2 = input("Enter another string: ")
result = ""
for i in string1:
    if (i.isupper()):
        result = result + i
for i in string2:
    if (i.isupper()):
        result = result + i
print("String1: " + string1)
print("String2: " + string2)
print(result)