Inactive Tutor answered 07/18/21
Maggie D.
asked 07/17/21Trouble starting a payroll program on Python. How to to force the number to be 0 or positive.
Write a program to calculate gross income and net income for all employees in a company. The user will input how many employees each time this program is executed. Number of employees can be zero, but cannot be negative.
Use a while loop to force the input to be zero or a positive integer (keep asking until a valid value is inputted).
Follow
1
Add comment
More
Report
1 Expert Answer
Tutor
New to Wyzant
# One of the ways
nmbr = -1
while (nmbr < 0):
typed = input('Enter number: ')
if typed.isdigit():
nmbr = int(typed)
else:
print("Wrong input")
Still looking for help? Get the right answer, fast.
Ask a question for free
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.