UPDATE : 2023-08-10 12:24
list.append(a)
list + [a]
list.pop()
"".join(list)
chars = list(input())
chars = map(str, input())
nums = map(int, input())
string[::-1]
string[a:b][::-1]
return str.startswith(target)
return str.endswith(target)
# 문자열은 배열이 아니라 특정위치값만 변경이 불가
array = array[:index]+char+array[index+1:]
# 문자열을 돌면서 확인하는 경우 배열 -> 문자열로 접근
strArray = list(array)
for index, arr in enumerate(strArray):
if arr == target:
strArray[index] = newValue
return ''.join(strArray)
ord(char)
chr(ord('a'))
return str.isdigit()
return str.islower()
return str.isupper()
str = str.lower()
str = str.upper()
str = str.swapcase()
str = str.replace('a', 'A')
문자열인 경우 find 사용 가능 (문자 찾기)
그 외는 index 함수를 사용
index = string.find(char)
# 없는 경우 -1 반환
index = array.index(value)
# 없는 경우 ValueError 반환
index = rfind(array)
# 없는 경우 -1 반환
reverseIndex = array[::-1].index(value)
index = len(array) - reverseIndex
리스트의 내장함수
array.sort()
array.sort(reverse=True)
array.sort(key=lambda x: abs(x-3))
array.sort(key=lambda x: abs(x-3), reverse=True)
이터러블을 정렬해주는 함수
array2 = sorted(array)
array2 = sorted(array, reverse=True)
array2 = sorted(array, key=lambda x: abs(x-3))
array2 = sorted(array, key=lambda x: abs(x-3), reverse=True)
iterable 중 func을 만족하는 것들만으로 이뤄진 iterable 객체 반환
arr = list(filter(lambda x: x>0, array))
arr = [str for str in array if 'a' in str]
from functolls import reduce
result = reduce(lambda x, y: x*y, array)
nums = list(map(int, ['1','2','3']))
abs(num)
from math import gcd
print(gcd(3, 6))
lcm 함수를 사용해도 되나, 기억이 안나는 경우
print(a*b//gcd(a, b))
for index, num in enumerate(array):
import copy
arr = copy.deepcopy(array)
from itertools import combinations
from itertools import permutations
from math import gcd
from math import lcm
from functools import reduce
from copy import deepcopy
https://docs.python.org/ko/3/library/stdtypes.html
https://velog.io/@matt2550/파이썬 - sort 정리
글 잘 봤습니다.