Do I need to adapt codes for SL? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

Do I need to adapt codes for SL?

Hello Everyone, Yesterday I wrote some code on my IDE and it works perfect. So, I wanted to post it on SL, but for some reason won't work in the same way. On SL I get an EOF-exeption. How do I solve this? *EDIT: The code can be found on my profile. Many thanks, Jay Aberlour

26th Feb 2018, 1:13 PM
Jay Aberlour
Jay Aberlour - avatar
6 Answers
+ 11
Hi Jay, It is a limitation of the compiler here. Since compiled code is run on the server and results sent back to your device, all inputs must be entered a runtime. In your case, unless the input is correct first time, 3 incorrect attempts must be entered in the displayed prompt to get the code to display access denied.
26th Feb 2018, 1:22 PM
jay
jay - avatar
+ 10
Instead of input() at the message for correct input, you need exit() or the loop continues to run
26th Feb 2018, 1:44 PM
jay
jay - avatar
+ 4
I think the issue is that it continues to search for username and password even after you submit the correct one. Try breaking out of the loop when you get it right. I'm not sure if python has the 'break' keyword, but that's what you need
26th Feb 2018, 1:48 PM
Zeke Williams
Zeke Williams - avatar
+ 4
@jay the input() is an trick I used in college. When you open an python-program, the CLI closes as soon as it reaches the end, but that's way to soon for a user. The input() makes the screen stay open. @Zeke Williams a break is certainly possible. But om my IDE this way works. Do you think the break wil solve the problem on SL?
26th Feb 2018, 2:15 PM
Jay Aberlour
Jay Aberlour - avatar
+ 3
Thank you Jay, Actually, I didn't even get to an wrong input. You're probably right, but the EOF-exeption starts as soon as an input is given.
26th Feb 2018, 1:40 PM
Jay Aberlour
Jay Aberlour - avatar
+ 3
I think it worked for me. It certainly can't hurt to try it :)
26th Feb 2018, 7:50 PM
Zeke Williams
Zeke Williams - avatar