0

I want to enter two numbers. If second number is 0 then I want the user to re-enter again and also be notified that zero is not allowed

the below code runs but no results.

I am calling a module called mainmod1 which has only functions for +, * and / defined :

import mainmod1
x = int(input("Enter A "))
y = int(input("Enter B "))

while y!=0:

    print("The  sum is ", mainmod1.sum1(x,y))
    print("The Multiplication is ", mainmod1.mul1(x,y))
    print("The Division is ", mainmod1.divi(x,y))
    break
    int(input("Enter Non Zero value for B "))
Joshua Varghese
  • 5,082
  • 1
  • 13
  • 34
  • Does this answer your question? [Asking the user for input until they give a valid response](https://stackoverflow.com/questions/23294658/asking-the-user-for-input-until-they-give-a-valid-response) – rdas Apr 12 '20 at 16:22

1 Answers1

1

You have all parts of the solution, put in a wrong order. What you want is:

import mainmod1
x = int(input("Enter A "))
y = int(input("Enter B "))
while y==0:
    y = int(input("Enter Non Zero value for B "))
print("The  sum is ", mainmod1.sum1(x,y))
print("The Multiplication is ", mainmod1.mul1(x,y))
print("The Division is ", mainmod1.divi(x,y))
Błotosmętek
  • 12,717
  • 19
  • 29