알고리즘/코드워

[python]Removing Elements

(ㅇㅅㅎ) 2020. 3. 20. 21:41
728x90
반응형

https://www.codewars.com/kata/5769b3802ae6f8e4890009d2/train/python

 

Codewars: Train your coding skills

Codewars is where developers achieve code mastery through challenge. Train on kata in the dojo and reach your highest potential.

www.codewars.com

 

인덱스 짝수 번호인 것 지우는 문제이다.

더보기

내 코드

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# My Code
def remove_every_other(my_list):
    answer = []
    for i in range(len(my_list)):
        if i % 2 == 0:
            answer.append(my_list[i])
    return answer
 
if __name__=='__main__':
    r = remove_every_other(['Hello''Goodbye''Hello Again'])
    print(r)
    r = remove_every_other([12345678910])
    print(r)
    r = remove_every_other([[12]])
    print(r)
    r = remove_every_other([['Goodbye'], {'Great''Job'}])
    print(r)
 
반응형

'알고리즘 > 코드워' 카테고리의 다른 글

[python]All Star Code Challenge#18  (0) 2020.03.26
[python]Will you make it?  (0) 2020.03.24
[python]CamelCase Method  (0) 2020.03.15
[python]Bouncing Balls  (0) 2020.03.14
[python]Simple Pig Latin  (0) 2020.03.13