Printing an error message
Go to solution
Solved by Guest,
# previous reading from user previousRead = input (str ("Please enter previous Gas Meter Reading: ")) previousReadLen = len (previousRead) # length of input data if previousReadLen < 4 : previousRead = int (previousRead) # switching from string to integer print ("ERROR IN THE PREVIOUS READING (USE FOUR DIGIT NUMBER(%.4d)). TRY AGAIN!" %previousRead) previousRead = int (previousRead) # switching from string to integer if previousRead < 0000 or previousRead > 9999 : print ("ERROR IN PREVIOUS READING (OUT OF RANGE:0000-9999). TRY AGAIN!") # current reading from user currentRead = input (str ("Please enter new Gas Meter Reading: ")) currentReadLen = len (currentRead) # length of input data if currentReadLen < 4 : currentRead = int (currentRead) # switching from string to integer print ("ERROR IN THE NEW READING (USE FOUR DIGIT NUMBER(%.4d)). TRY AGAIN!" %currentRead) currentRead = int (currentRead) # switching from string to integer if currentRead < 0000 or currentRead > 9999 : print ("ERROR IN NEW READING (OUT OF RANGE:0000-9999). TRY AGAIN!") elif currentRead < previousRead : currentRead = currentRead + 10000
Thanks @M.Yurizaki for you help! <3

Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now