你能帮我解决这个问题吗。我被测试用例1和2卡住了
def upper_1():
countCap = 0
while True:
word = input('Enter word or press Enter/Return key: ')
if word == '':
print("'0 words were entered'")
break
else:
if word[0].isupper():
countCap += 1
if word != '':
print('Words with first letter in upper case = ', str(countCap))
代码中有一些逻辑错误。一些小的修复可以:
或者稍微缩短一点:
相关问题 更多 >
编程相关推荐