Last answered:

20 Feb 2024

Posted on:

20 Feb 2024

0

Confused about the print("Out of range")

Except if I do not undertand this, the input stated  "Guess a number between 1-10" why would there be a need to input "pineapple" or "12"  or even the isdigit() method? 


By the way, great content! Thank you! 


Charlemagne

1 answers ( 0 marked as helpful)
Instructor
Posted on:

20 Feb 2024

0

Hey Charlemagne,


Thank you for reaching out and for your positive feedback!


In the development of software, particularly those intended for a wide audience, it is of utmost importance to test each scenario. As developers, we must expect every potential user interaction, rather than assuming users will interpret and follow instructions precisely.


Let's consider the exercise in the lesson. It's important to verify whether an input is a digit in order to successfully compare it with the secret number. This prevents the program from crashing in case the user enters an input of a different data type, either erroneously or intentionally. We'd never want a user to experience a program crash. Instead, we should guide them with clear feedback on the expected input type and prompt them to try again. In this way, we protect the integrity of the program and ensure it remains accessible to users of all proficiency levels.


This idea will become even clearer once you reach Section 23: Exception Handling in Python.


Hope this helps! Let me know if there's anything else I can help with.


Kind regards,

365 Hristina

Submit an answer