할껀하고놀자

파이썬 기초 300제(13) - and or 본문

[IT]/Python300제

파이썬 기초 300제(13) - and or

working_hard 2019. 9. 20. 14:32
728x90

직관적이어서 좋은 것 같다.

# 131
my_list = ["가", "나", "다", "라"]
for m in my_list[1:]:
    print(m)
# 132
my_list = [1, 2, 3, 4, 5, 6]
for m in my_list[::2]:
    print(m)
# 133
my_list = [1, 2, 3, 4, 5, 6]
for m in my_list[1::2]:
    print(m)
my_list = ["가", "나", "다", "라"]
for m in my_list[::-1]:
    print(m)
# 134
my_list = [3, -20, -3, 44]
for m in my_list:
    if m<0:
        print(m)
# 135
my_list = [3, 100, 23, 44]
for m in my_list:
    if m%3==0:
        print(m)
# 136
my_list = ["I", "study", "python", "language", "!"]
for m in my_list:
    if len(m)>3:
        print(m)
# 137
my_list = [3, 1, 7, 10, 5, 6]
for m in my_list:
    if 5<m<10:
        print(m)
# 138
my_list = [13, 21, 12, 14, 30, 18]
for m in my_list:
    if 10<m<20 and m%3==0:
        print(m)
my_list = [3, 1, 7, 12, 5, 16]
for m in my_list:
    if m%3==0 or m%4==0:
        print(m)
Comments