Q ) 문자열로 구성된 리스트의 합계를 구하는 함수를 생성하세요.
testList = ["11","22"]
answer = customSumFunction(testList)
answer -> 33
# 문자리스트 합
def stringNumberSum(inputList):
for i in range(0,len(inputList),):
inputList[i] = int(inputList[i])
return sum(inputList)
# 문자리스트 평균
def stringNumberAvg(inputList):
for i in range(0,len(inputList),):
inputList[i] = int(inputList[i])
return sum(inputList) / len(inputList)
# 문자 -> 실수
def stringToDouble(inputList):
for i in range(0,len(inputList),):
inputList[i] = int(inputList[i])
return inputList
# 문자 -> 정수
def stringToInt(inputList):
for i in range(0,len(inputList),):
inputList[i] = int(inputList[i])
return inputList
# 숫자 -> 문자
def numberToString(inputList):
for i in range(0,len(inputList),):
inputList[i] = str(inputList[i])
return inputList
'개발자 > Python' 카테고리의 다른 글
Python (파이썬) for문 심화 및 데이터 정제 심화 문제 (0) | 2020.04.26 |
---|---|
Python (파이썬) DB 엔진을 활용, Pandas로 SQL을 이용해 불러오고 내보내기 (0) | 2020.04.26 |
Python (파이썬) 깃허브에서 가져오기 (0) | 2020.04.26 |
Python (파이썬) Pandas 모듈 (with d6tstack 모듈) (0) | 2020.04.26 |
for문 별찍기 3중 트리 (0) | 2020.04.25 |