+ 1
What am i missing?
I'm trying to write a Drunkard's Walk code that can handle improper user input through ValueError exception. First version (https://www.sololearn.com/en/compiler-playground/cIyAg0ZwZlq2) performs as expected, as long as user input are numbers but it throws error when user enters a letter. Second version (https://www.sololearn.com/en/compiler-playground/cnpWWb82iOA4) keeps notifying that values need to be checked even when numbers are correctly spaced (lowest, highest, then middle), but it handles letter input as intended (for example - 5, 15, 1o (notice the letter "o" in place of the zero)). Which one is closer to the solution?
2 odpowiedzi
+ 5
Igor Matić ,
the following code (in the attached file) demonstrates how input can be done, checked, and user can be prompted to repeate the input in case of an invalid input. this works in a regular ide, but has some difficulties in sololearn playground
https://sololearn.com/compiler-playground/cDBh0304mU14/?ref=app
+ 1
Lothar thank you for the code. However, i didn't completely understand the rest of the syntax, as i don't completely understand the basic syntax yet, instead i revised the second version of my code and managed to get it to work properly, check for and handle both mismatched values and wrong input type.
Would there be any other set of inputs that my code doesn't handle in its current form?