기타 제어 흐름 도구
ifif x for루프의 else 절은 break가 발생하지 않을 때 실행for n in range(2, 10): for x in range(2, n): if n % x == 0: print(n, 'equals', x, '*', n//x) break else: # loop fell through without finding a factor print(n, 'is a prime number')결과2 is a prime number3 is a prime number4 equals 2 * 25 is a prime number6 equals 2 * 37 is a prime number8 equals 2 * 49 equals 3 * 3pass 문pas..
개발 언어/파이썬
2024. 7. 9. 22:50