a=[1,2,3,4] b=iter(a) next(b) 1 next(b) 2 list(b) [3,4]
def gen(): yield 1 yield 2 # yield from [1,2]로 쓸 수 있음 # type(gen)은 class 'function' gg=gen() # type(gg)는 class 'generator' next(gg) 1 next(gg) 2 next(gg) StopIteration
names = ["alice", "bob", "charlie"] upper_names = list(map(str.upper, names))
words = ["apple", "banana", "cherry", "date"] sorted_words = sorted(words, key=lambda x: len(x))