"HR파이썬 Lists"의 두 판 사이의 차이

(새 문서: ==개요== ;{{subst:PAGENAME}} * {{HR파이썬 헤더}} {{HR파이썬 Basic Data Types}} |} ---- <source lang='python'> </source> <source lang='python'> </source>)
 
잔글 (봇: 자동으로 텍스트 교체 (-</source> +</syntaxhighlight>, -<source +<syntaxhighlight ))
 
(다른 사용자 한 명의 중간 판 2개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;HR파이썬 Lists
;HR파이썬 Lists
*  
* https://www.hackerrank.com/challenges/python-eval/problem


{{HR파이썬 헤더}}
{{HR파이썬 헤더}}
9번째 줄: 9번째 줄:
----
----


<source lang='python'>
<syntaxhighlight lang='python'>
</source>
if __name__ == '__main__':
<source lang='python'>
    N = int(input())
</source>
    lst = []
    for _ in range(N):
        command, *params = input().split()
        if command == 'insert':
            i, e = map(int,params)
            lst.insert(i, e)
            continue
        if command == 'print':
            print( lst )
            continue
        if command == 'remove':
            e = int(params[0])
            lst.remove(e)
            continue
        if command == 'append':
            e = int(params[0])
            lst.append(e)
            continue
        if command == 'sort':
            lst.sort()
            continue
        if command == 'pop':
            lst.pop()
            continue
        if command == 'reverse':
            lst.reverse()
            continue
</syntaxhighlight>

2021년 7월 31일 (토) 10:53 기준 최신판

개요[ | ]

HR파이썬 Lists
해커랭크 Python
# 문제 비고
HR파이썬 Basic Data Types e
8 HR파이썬 List Comprehensions
9 HR파이썬 Find the Runner-Up Score!
10 HR파이썬 Nested Lists
11 HR파이썬 Finding the percentage
12 HR파이썬 Lists
13 HR파이썬 Tuples

if __name__ == '__main__':
    N = int(input())
    lst = []
    for _ in range(N):
        command, *params = input().split()
        if command == 'insert':
            i, e = map(int,params)
            lst.insert(i, e)
            continue
        if command == 'print':
            print( lst )
            continue
        if command == 'remove':
            e = int(params[0])
            lst.remove(e)
            continue
        if command == 'append':
            e = int(params[0])
            lst.append(e)
            continue
        if command == 'sort':
            lst.sort()
            continue
        if command == 'pop':
            lst.pop()
            continue
        if command == 'reverse':
            lst.reverse()
            continue
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}