samedi 10 novembre 2018

Finding the Range

Hi so for homework I have to type up a program where it will accept two numbers. If one of the numbers on the left is smaller than the one on the right, it will increase. If the second number is smaller than the first number than it will decrease. If both numbers are the same then it should stay the same. Here the program I had written so far:

def range_of_numbers (number1, number2):
if (number2 > number1):
    for num1 in range (1):
        print (2, 3, 4, 5, 6, 7 )
elif (number1 > number2):
    for num2 in range (1):
        print (19, 18, 17, 16, 15, 14, 13, 12, 11)
else:
    print (42)

The sample calls are: range_of _numbers (2, 8) range_of_numbers (18, 11) range_of_numbers (42, 42) I got two of them right, but the last one keeps getting the wrong output and i dont know what wrong or where the mistake to fix it.

Aucun commentaire:

Enregistrer un commentaire