-
python - tip : 원하는 조건의 값을 받아내기 전까지 반복Python/tip of python 2020. 7. 13. 20:25
원하는 조건의 값이 입력되면 종료, 그렇지 않으면 반복되는 구문.
while True:
try:
a = int(input("input integer for a from -10 to 10 : "))
if a>=-10 and a<=10:
break # while문 정지
except ValueError:
print("That was no valid number. Try again...") # 문자나 기호가 입력되면 이 글이 나오고 다시 시도.'Python > tip of python' 카테고리의 다른 글
xlwings 라이브러리에서 좌표로 내용 입력하는 함수 (0) 2020.08.19 python - 빠진 자리 data (missingno) (0) 2020.07.20 installing libraries on conda (0) 2020.07.20 data frame 문자열 다루기 (0) 2020.07.16 a, b값 바꿔치기(상호 교환) (0) 2020.07.13