-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathex_08_06.py
43 lines (39 loc) · 821 Bytes
/
ex_08_06.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
print("Exercise 8.6")
ls = []
# Method 1
# while True:
# num = input("Enter a number: ")
# if num != "done":
# num = float(num)
# ls.append(num)
# else:
# break
# Method 2
# while True:
# num = input("Enter a number: ")
# if num != "done":
# try:
# num = float(num)
# except:
# print("Error, please try again")
# else:
# ls.append(num)
# else:
# break
# Method 3
while True:
num = input("Enter a number: ")
if num == "done":
break
else:
try:
num = float(num)
except:
print("Error, please try again")
else:
ls.append(num)
max_num = max(ls)
min_num = min(ls)
print(ls)
print("Maximum:", max_num)
print("Minimum:", min_num)