Question: My program is supposed to take a negative integer value from the user and determine whether or not that value is evenly divisible by either
My program is supposed to take a negative integer value from the user and determine whether or not that value is evenly divisible by either 5 or 7. In order to end the loop the user should just have to input a positive number or a 0. The program works fine except for when I enter a 0. Instead of ending the loop it just displays the message that 0 is evenly divisible by 5 or 7. I'm not sure how to modify the program in order to end the loop whenever 0 is inputted. end_loop = False num_integers = 0 while not end_loop: negative_integer = int(input("Please enter a negative integer (0 or positive to end): ")) if negative_integer % -5 == 0 or negative_integer % -7 == 0: print("Negative integer is evenly divisible by either 5 or 7.") num_integers += 1 elif negative_integer >= 0: end_loop = True print("Evenly divisible numbers are:", num_integers) Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
