Python Glitch
Hello, I'm self-enrolled in the Python 3 course.
I'm trying to print all numbers in a range on the same line, and am using the code:
a = int(input())
b = int(input())
for i in range(a, b + 1):
print(i, end=' ')
the model solution (I used a different code to submit it that did work) is the same exact thing. However, although it works in the model solution, it doesn't work in the student area. This is because of the end = ' ' code, which allows it to print on the same line instead of different ones. Instead of working, the program prints nothing, even though (i triple checked) it is the same exact thing as the model solution.
I need this code to work for a following assignment on the same classroom, but it won't work because of the glitch. I was wondering how this could be fixed? I know that it's not my particular account becuase it's not working for my friend, either.
How bizarre! The end argument has always been perfectly functional for me. Could you post some screenshots or videos or something of it not working?
Also having an issue with the end argument in repl.it.
Have a similar code, that's meant to simulate someone typing letter-by-letter, that I had forked from another repl. It didn't run at the time and I figured maybe it was because it was a python 2.7 code and I usually run in python3. I copied and pasted the code into my own and it worked, until I exited the repl.
I can repeat this so I'm sure there's some bug here. If you copy your code and paste into a new repl, it will run fine until you close that repl. Then it will never work again (My program just does nothing for 20 seconds, and then spit the whole string just as one blob. You can keep copying and paste to new repl to get it to work for that session, but I can't seem to figure out why it stops after you close the session.
Seems to only not work in repl. Works fine when I run it on my computer.
By the way, if you don't have to have the code look exactly like that, this works in repl.it and is a one-liner:
print(' '.join([str(x) for x in range(int(input()),int(input())+1)]))
EDIT:
Seems like passing end as a parameter doesn't work no matter what you're printing: https://imgur.com/CO18ne5
cool
Are there tests that are failing? If so, can you post screenshots of the failing tests? It should give a hint as to why it's not working.
This indeed seems to be a bug on our end - we're looking into it. Sorry about this.
@timmy_i_chen
ahh okay! If you need screenshots, here they are:
This file cannot be displayed: https://storage.googleapis.com/replit/images/1532034676831_51d1675fd9fbd9e39e1fdfad2b1fc1cc.pn
This picture is how I'm solving it so I can see the model solution
This file cannot be displayed: https://storage.googleapis.com/replit/images/1532034710690_349b1a84389a244783f02499c886b024.pn
This picture is the model solultion. If you look in the dark area, that's me trying to run it, but the output is only just a space. If I try to do this and submit it, then all tests will fail.
@AmberTheCorgi Sorry about this - this should be fixed soon when we release the new terminal.
As a workaround, and to offer an alternate solution, you can get around this by not using
end=
and instead create a new variableresult
as an empty string and addingstr(i) + ' '
to the end ofresult
. Does that make sense?