반응형
def lowercase(string):
lowercaseStr = ""
for index in range(len(string)):
# Condition : uppercase letter, replace uppercase letter to lowercase letter
if(65 <= ord(string[index]) and ord(string[index]) <= 90):
asciiIndex = ord(string[index]) + 32
lowercaseStr += chr(asciiIndex)
# Condition : lowercase letter, Just adds on original letter
else:
lowercaseStr += string[index]
return lowercaseStr
print (lowercase("Hi Cassie! COLLEGE station weather is REALLY HoT"))
* ord function
: It is a inbuilt function return an integer representing the Unicode code
Examples:
Input : a Output : 97
Reference site : https://www.geeksforgeeks.org/ord-function-python/
* chr function
: It is a inbuilt function that converts ASCII-based number to character
Syntax:
chr(num) num : integer value
Reference site : https://www.geeksforgeeks.org/chr-in-python/
반응형
'<개인공부> - IT > [Python]' 카테고리의 다른 글
Number of Things Challenge 함수 만들기 (0) | 2018.08.20 |
---|---|
Commafy 함수 만들기 (0) | 2018.08.20 |
Gerund 판단 함수만들기 (0) | 2018.08.20 |
Reverse String 함수 만들기 (0) | 2018.08.20 |
isupper(), islower() 함수이용하여 문자열의 대소문자 변경하기 (0) | 2018.08.19 |