无需使用函数即可将字符小写的Python程序

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

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值