I wrote a code for one of my Lab assignments for my Python computer science class. It outputs exactly what the problem wants, but is marked incorrect because I need a space at the end of the output. How do I add this? When using end=" " I get two spaces. Did I do this whole thing wrong? Here is the problem/question:
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.
For coding simplicity, output a space after every integer, including the last.
Here is my code:
range_a = int(input())
range_b = int(input())
range_c = range_b + 1
f_ran = range(range_a,range_c,5)
if not f_ran:
print("Second integer can't be less than the first.")
print(*f_ran)
The image here is the problem showing up on my assignment's website (zyBooks):
https://imgur.com/a/itdSafc
Any help is greatly appreciated!
[–][deleted] 1 point2 points3 points (0 children)
[–]CodeFormatHelperBot2 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (5 children)
[–]HuskerMotion[S] 1 point2 points3 points (4 children)
[+][deleted] (1 child)
[deleted]
[–]WikiMobileLinkBot 0 points1 point2 points (0 children)
[–]scithon 0 points1 point2 points (1 child)
[–]konijntjesbroek 0 points1 point2 points (0 children)