# This program adds input validation to make_collatz_seq.py

# Add try and except statements to the previous project to detect whether
# the user types in a noninteger string. Normally, the int() function will
# raise a ValueError error if it is passed a noninteger string, as in int('puppy').
# In the except clause, print a message to the user saying they must enter an integer.

from P01_make_collatz_seq import collatz

try:
    n = int(input("Input a number: "))
    while n != 1:
        print(n)
        n = collatz(n)
    print(n)  # When n == 1
except ValueError:
    print("Error: Input must be an integer.")

@@ -1,10 +1,29 @@
-# 
+%22%22%22Input validation%0A%0A
 This pro
@@ -52,16 +52,30 @@
 tion to 
+:py:mod:%60.P01_
 make_col
@@ -86,15 +86,11 @@
 _seq
-.py%0A%0A# 
+%60%0A%0A
 Add 
@@ -157,18 +157,16 @@
 whether%0A
-# 
 the user
@@ -214,13 +214,18 @@
 the 
+:obj:%60
 int
-()
+%60
  fun
@@ -239,18 +239,16 @@
 ill%0A
-# 
 raise a 
 Valu
@@ -243,16 +243,24 @@
 raise a 
+:class:%60
 ValueErr
@@ -261,16 +261,17 @@
 lueError
+%60
  error i
@@ -312,16 +312,17 @@
 , as in 
+%60
 int('pup
@@ -329,12 +329,11 @@
 py')
+%60
 .%0A
-# 
 In t
@@ -418,13 +418,37 @@
 r.%0A%0A
+%0A%22%22%22%0A%0A%0Adef main():%0A    
 from 
+.
 P01_
@@ -484,13 +484,21 @@
 tz%0A%0A
+    
 try:%0A
+    
     
@@ -532,16 +532,20 @@
 er: %22))%0A
+    
     whil
@@ -558,24 +558,28 @@
  1:%0A        
+    
 print(n)%0A   
@@ -571,24 +571,28 @@
    print(n)%0A
+    
         n = 
@@ -602,24 +602,28 @@
 latz(n)%0A    
+  
+  
 print(n)  # 
@@ -634,16 +634,20 @@
  n == 1%0A
+    
 except V
@@ -657,16 +657,20 @@
 eError:%0A
+    
     prin
@@ -707,8 +707,48 @@
 eger.%22)%0A
+%0A%0Aif __name__ == %22__main__%22:%0A    main()%0A

Update P02_input_validation.py added docstring and wrapped in main() function