I've written function enterReadings for the user to enter a number and I've got the following verification to ensure it's a positive integer. I'm thinking that there's a simpler way to write this but don't know where to start, any help is massively appreciated!
def enterReadings(message): while True: try: readingsCount = int(input(message)) if readingsCount <= 0: print("Please enter a positive integer") continue break except ValueError: print("Please enter a positive integer") readingsCount = 0 if readingsCount > 0: readingsCount += readingsCount return readingsCount
if readingsCount > 0to check for a +ve number should be good enough.ifcan be removed and the lines under it should replace thebreak. I don't think thatbreakdoes what you mean anyway.Noneif a positive integer was entered?