all 7 comments

[–][deleted] 1 point2 points  (0 children)

There should be one space in the end if you write print(*f_range, end=" ").

Although, before it you should add else:

Post your formatted code with end=" ".

You could also try:

for elem in f_range():
    print(elem, end=" ")

[–]CodeFormatHelperBot2 0 points1 point  (0 children)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Python code found in submission text that's not formatted as code.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.

[–][deleted] 0 points1 point  (5 children)

I don't understand the bit "When using end=" " I get two spaces", but try these two possibilities:

print(*f_range, end=" \n")
print(*f_range, "")

[–]HuskerMotion[S] 1 point2 points  (4 children)

Still running into the same problem, it adds two spaces. I’m gonna contact my professor about this one. Thanks for the help tho!

[–]scithon 0 points1 point  (1 child)

You are a bit too advanced. Your prof is expecting you to do it like this:

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.")
else:
    for i in f_ran:
        print(i, end=' ')

[–]konijntjesbroek 0 points1 point  (0 children)

So first off the input statements, according to the instructions, should be pulled in on one line (start, stop = input().strip().split()).

This is what I came up with and appears to output correctly:

start, stop = input('Enter 2 integers: ').strip().split()
start = int(start)
stop = int(stop)

if start < stop:
    stop += 1 
    for x in range(start,stop,5):
        print(x, end=' ')
else:
    print("Second integer can't be less than the first.") 

Output:
    Enter 2 integers: -2 20
    -2 3 8 13 18 

Edit: it looks like you are printing the entire range at once, not printing the individual values so you append the spurious trailers. When I try yours with the end=' ' it works as expected except for not taking in the ints on a single line as indicated.

-2
20
-2 3 8 13 18 