Skip to content

Commit 8cae80f

Browse files
author
weiyanhua
committed
process user error input
1 parent 3d4ee06 commit 8cae80f

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

chaos.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@
22

33
def main():
44
print ("This program illustrates a chaotic function")
5-
x = float((input("Enter a number between 0 and 1: ")))
5+
6+
while True:
7+
try:
8+
x = float((input("Enter a number between 0 and 1: ")))
9+
if (0 < x and x < 1):
10+
break
11+
else:
12+
print("Please enter correct number")
13+
except Exception as e:
14+
print("Please enter correct number")
15+
616
for i in range(10):
717
x = 3.9 * x * (1-x)
818
print (x)

0 commit comments

Comments
 (0)