我必须创建一个仅使用 ord 和 chr 函数将小写字母更改为大写字母的函数。
这是我到目前为止所拥有的,但问题是它没有返回所有字母,只返回第一个字母。
def changeToUpperCase(text):
for i in text:
i = ord(i) - 32
text = chr(i)
return text
def main():
text = input("Please type a random sentence.")
text = changeToUpperCase(text)
print("Step 2 -> ", text)