largest = 0
smallest = None
while True:
num = input("Enter a number: ")
if num == "done":
break
try :
num = int(num)
if smallest is None:
smallest = num
elif num < smallest :
smallest = num
if num > largest:
largest = num
except:
print('Invalid input')
print("Maximum is", largest)
print("Minimum is", smallest)
결과
'모두를 위한 Python 특화과정 > 20171047 김동훈' 카테고리의 다른 글
python 데이터 구조-2 (0) | 2022.07.27 |
---|---|
python 데이터 구조-1 (0) | 2022.07.19 |
Programming for Everybody (Getting Started with Python)-6 (0) | 2022.07.19 |
Programming for Everybody (Getting Started with Python)-5 (0) | 2022.07.19 |
Programming for Everybody (Getting Started with Python)-4 (0) | 2022.07.19 |