We help IT Professionals succeed at work.
Get Started

How to print an error message and exit after a while loop ends?

Barbara69
Barbara69 asked
on
289 Views
Last Modified: 2014-08-20
I have a program in python 3 with a global variable for my counter, while counter <= 3, gets the user input, goes to a function to validate and increments the counter in the validation function. After three invalid data entries in a row, it needs to display an error message and exit. It exits the while loop after the three invalid attempts in a row, but I don't know where to put the error message and how to make it exit. If the user enters invalid data, say twice and the third time enters good data how to reset the counter and start the process all over again.
Comment
Watch Question
Principal Data Engineer
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 11 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE