파이썬 별 피라미드
-
38 - reversed() 함수와 별 피라미드 - 추가연습 필요study with Q - 파이썬 2024. 4. 22. 21:56
#reversed() 함수 : 매개변수로 반복 가능한 것을 넣으면 결과로 그것을 뒤집어서 나타내줌 : 결과 자료형 : 이터레이터 반복가능한 자료형이라고 나오기는 하는데 나중에 배울 예정... #리스트에 reversed() 함수를 적용해보기 reversed([0,1,2,3,4])로 리스트에 reversed() 함수를 적용해보고 결과를 볼 수 있게 list 함수와 print로 감싸면 print(list(reversed([0,1,2,3,4]))) >>> [4, 3, 2, 1, 0] #딕셔너리에 reversed() 함수를 적용해보기 는 많지 않아서 생략 #범위에 reversed() 함수를 적용해보기 reversed(range(0, 9+1)) print(list(reversed(range(0, 9+1)))) >>..