0

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?

11th Mar 2025, 2:09 PM
Igor Matić
Igor Matić - avatar
1 ответ
+ 1
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
11th Mar 2025, 9:29 PM
Lothar
Lothar - avatar