125k views
0 votes
Write a program whose input is two integers. Output the first integer and subsequent increments of 5 as long as the value is less than or equal to the second integer.

Ex: If the input is:

-15
10
the output is:

-15 -10 -5 0 5 10
Ex: If the second integer is less than the first as in:

20
5
the output is:

Second integer can't be less than the first.

User Vergil
by
8.4k points

1 Answer

4 votes

Answer:

def increment_sequence(first, second):

if second < first:

print("Second integer can't be less than the first.")

else:

output = str(first)

while first + 5 <= second:

first += 5

output += " " + str(first)

print(output)

# Get input from the user

first = int(input("Enter the first integer: "))

second = int(input("Enter the second integer: "))

# Call the function

increment_sequence(first, second)

User Edward Strange
by
8.8k points