Dec-03-2018, 04:53 PM
So i have an assignment to count in increments and display them.
here is what I have :
2nd, when the answer is tallied, i want it to stop at the end value (eValue) instead of going over. so if the inputs are 1, 20 and 2. right now it'll output until 21, but i want it to stop at 20.
How do i do that?
here is what I have :
play= True while play: try: sValue=int(input("Enter the starting value --> ")) except ValueError: print("Please enter an integer.\n> ") try: eValue=int(input("Enter the ending value --> ")) except ValueError: print("please enter an integer.") try: iValue=int(input("Enter the increments you'd like to count in --> ")) except ValueError: print("Please enter an integer.") print("Lets beging counting, starting with", sValue, "and ending with", eValue) while sValue < eValue: sValue += iValue print("Value is " + str(sValue)) again=str(input("Would you like to try again? ")).lower() if again == "no": play = FalseI have 2 questions. When the input is invalid (valueerror) it moves on to the next input, i need it to re-ask the question.
2nd, when the answer is tallied, i want it to stop at the end value (eValue) instead of going over. so if the inputs are 1, 20 and 2. right now it'll output until 21, but i want it to stop at 20.
How do i do that?