Input exception handling in sololearn codes, yes or no? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Input exception handling in sololearn codes, yes or no?

Since we can't let other users repeat faulty inputs and interact with them freely and since we have to rely on the initial mass input anyway, I'm feeling somewhat meh about it, this here being kind of a special situation, everyone actually reading and hopefully understanding the other's codes, and also 'we're all consenting adults here' blah blah ... Or am I taking this too lightly, what do you think?

24th Jul 2018, 8:17 PM
HonFu
HonFu - avatar
6 Answers
+ 3
No, I'm talking about specific measures in the code, preventing a program crash. Something like: print ('Please enter an int!') while True: try: x=int (input) break except: print ('Enter an int, I said!!!') When you do that sort of stuff, it takes up a lot of space in the code and makes it harder or less pleasant to read. Therefore my question: Should we do it here on sololearn, where we basically only demonstrate stuff to each other? Maybe an IRL example: This code here is supposed to work with even numbers >= 4, but you can input virtually anything you like - then you'll get an error message though). https://code.sololearn.com/cLHqrOVDRqX0/?ref=app
25th Jul 2018, 1:56 PM
HonFu
HonFu - avatar
+ 2
You know, like when you want an int, but user types letters instead, or you want a positive number and he gives a negative one ... stuff like that. IRL we would write try, except, raise or whatnot quite a few times, but since we're not really endusers, what's the point? Who wants to read all this "You should have done this and that" in a code example? Or do you think, we should always clean up the place?
25th Jul 2018, 12:56 PM
HonFu
HonFu - avatar
+ 2
got it , and yes u have a point ..
25th Jul 2018, 2:55 PM
Shimaa
Shimaa - avatar
+ 2
Most of the time in Sololearn lessons you will see small examples. The purpose is to teach something so you will almost never see this kind of structur (try, except). Thus codes remains centered on the lesson. It is enough for us because we want to learn/teach ourselves (the community). As said: we are not the end users. Enjoy coding :)
16th Aug 2018, 3:29 PM
Antoine
+ 1
input exception handlin ?
25th Jul 2018, 12:48 PM
Shimaa
Shimaa - avatar
+ 1
so u mean should we write explanation for everycode we write to tell others how to u use or what to input ? did i get it ?
25th Jul 2018, 1:45 PM
Shimaa
Shimaa - avatar