<filename>Exception_handling.py<gh_stars>0
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 27 15:20:52 2018

@author: kampa_000
"""
"""
It's a loop, which breaks only, if a valid integer has been given. 
The example script works like this:
The while loop is entered. The code within the try clause will be executed statement 
by statement. If no exception occurs during the execution, the execution will reach the
break statement and the while loop will be left. If an exception occurs, i.e. in the casting 
of n, the rest of the try block will be skipped and the except clause will be executed. 
The raised error, in our case a ValueError, has to match one of the names after except. 
In our example only one, i.e. "ValueError:". After having printed the text of the print 
statement,the execution does another loop. It starts with a new raw_input().

"""
# =============================================================================
# while True:
#     try:
#         n = input("Please enter an integer: ")
#         n = int(n)
#         break
#     except ValueError:
#         print("No valid integer! Please try again ...")
# print ("Great, you successfully entered an integer!")
# =============================================================================


        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
<filename>Exception_handling.py<gh_stars>0
# -*- coding: utf-8 -*-
"""
Created on Wed Jun 27 15:20:52 2018

@author: kampa_000
"""
"""
It's a loop, which breaks only, if a valid integer has been given. 
The example script works like this:
The while loop is entered. The code within the try clause will be executed statement 
by statement. If no exception occurs during the execution, the execution will reach the
break statement and the while loop will be left. If an exception occurs, i.e. in the casting 
of n, the rest of the try block will be skipped and the except clause will be executed. 
The raised error, in our case a ValueError, has to match one of the names after except. 
In our example only one, i.e. "ValueError:". After having printed the text of the print 
statement,the execution does another loop. It starts with a new raw_input().

"""
# =============================================================================
# while True:
#     try:
#         n = input("Please enter an integer: ")
#         n = int(n)
#         break
#     except ValueError:
#         print("No valid integer! Please try again ...")
# print ("Great, you successfully entered an integer!")
# =============================================================================


        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
        
# -*- coding: utf-8 -*- Created on Wed Jun 27 15:20:52 2018
 
 @author: kampa_000 It's a loop, which breaks only, if a valid integer has been given. 
 The example script works like this:
 The while loop is entered. The code within the try clause will be executed statement 
 by statement. If no exception occurs during the execution, the execution will reach the
 break statement and the while loop will be left. If an exception occurs, i.e. in the casting 
 of n, the rest of the try block will be skipped and the except clause will be executed. 
 The raised error, in our case a ValueError, has to match one of the names after except. 
 In our example only one, i.e. "ValueError:". After having printed the text of the print 
 statement,the execution does another loop. It starts with a new raw_input(). # ============================================================================= # while True: #     try: #         n = input("Please enter an integer: ") #         n = int(n) #         break #     except ValueError: #         print("No valid integer! Please try again ...") # print ("Great, you successfully entered an integer!") # =============================================================================