#!/usr/bin/python
def brokenSanitizeString(s):
"""How I sanitize?"""
allowed = "abcdefghijklmnopqrstuvwxyz1234567890()+-/*^, "
for ch in s:
if ch not in allowed:
print "Invalid Character:", ch
return -1
return s
def calculator(s):
"""Pretends to be a calculator"""
print "About to Calculate:"
s = brokenSanitizeString(s)
if s == -1:
print "Please enter a mathematical operation"
return
print "Calculating:", s
try:
print "Equals:",eval(s)
except:
print "Please enter a mathematical operation"
def main():
print "Welcome to the online calculator. Please enter your expression below."
calculator(raw_input())
main()