try:
    for i in ['a','b','c']:
        print i**2
except:
    print "An error occurred!"

"""
Explanation: Errors and Exceptions Homework - Solution
Problem 1
Handle the exception thrown by the code below by using try and except blocks.
End of explanation
"""


x = 5
y = 0
try:
    z = x/y
except ZeroDivisionError:
    print "Can't divide by Zero!"
finally:
    print 'All Done!'

"""
Explanation: Problem 2
Handle the exception thrown by the code below by using try and except blocks. Then use a finally block to print 'All Done.'
End of explanation
"""


def ask():
    
    while True:
        try:
            n = input('Input an integer: ')
        except:
            print 'An error occurred! Please try again!'
            continue
        else:
            break
            
        
    print 'Thank you, you number squared is: ',n**2

ask()

"""
Explanation: Problem 3
Write a function that asks for an integer and prints the square of it. Use a while loop with a try,except, else block to account for incorrect inputs.
End of explanation
"""


