DEV Community

Discussion on: Day 3 of 100DaysOfCode: Python Program To Calculate Electric Bill

Collapse
 
nitinkatkam profile image
Nitin Reddy

UPDATE: I searched and found a ".isdigit()" method for strings which helps check if the string contains a positive integer. You can use ".isdigit()" instead of ".isnumeric()".

To allow negative numbers (Eg. when the electric company is unable to get the meter reading and uses an average-unit-count to bill you for the month, the next number of units can be in the negative), you can use an "or" in the condition with input_text.starts_with("-") and input_text[1:].isdigit()

Collapse
 
iamdurga profile image
Durga Pokharel

Thank you for sharing.