In this article, we will go for de-capitalizing the characters i.e. conversion from lowercase to uppercase without using any function. This article is based on the concept that how inbuilt function performs this task for us.
在本文中,我们将对字符进行去大写,即不使用任何功能就将其从小写转换为大写 。 本文基于内置函数如何为我们执行此任务的概念。
Writing code to take user input as a string and then de-capitalize every letter present in the string.
编写代码以将用户输入作为字符串,然后对字符串中出现的每个字母大写。
So, let's write a program to perform this task.
因此,让我们编写一个程序来执行此任务。
Key: The difference between the ASCII value of A and a is 32
密钥: A和a的ASCII值之差为32
Example:
例:
Input:
Hello world!
Output:
hello world!
Python code to lowercase the character without using a function
无需使用函数即可将字符小写的Python代码
# Python program to lowercase the character
# without using a function
st = input('Type a string: ')
out = ''
for n in st:
if n not in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
out = out + n
else:
k = ord(n)
l = k + 32
out = out + chr(l)
print('----->', out)
Output
输出量
First run:
Type a string: Hello world!
-----> hello world!
Second run:
Type a string: HHJHJHFF$%*@#$
-----> hhjhjhff$%*@#$
Third run:
Type a string: abcds14524425way
-----> abcds14524425way
Practice more python experiences here: python programs
在这里练习更多python经验: python程序
翻译自: https://www.includehelp.com/python/program-to-lowercase-the-character-without-using-a-function.aspx