Input validation for pi.py