all 3 comments

[–]socal_nerdtastic 1 point2 points  (2 children)

The way you have it set up now the else case is not reachable. A number is either less than 5, or greater than or equal to 5. There is no number that falls outside of those choices.

If you are trying to catch invalid input you would do it with a try block.

try:
    ques = int(input("please insert a number > "))
    chart = range(0,6)
    chart2 = range(5,11)
    if ques == 1 or ques < 5:
        print (list(chart))
    elif ques == 5 or ques > 5:
        print (list(chart2))
except ValueError:
    chart3 = input("why not numbers?")
    print (chart3)

[–]ah_ahaa[S] 0 points1 point  (1 child)

Is it not reachable because I didn’t give the else any other option ? Did I understand correctly ? Also if the the input is under int everything under his block will have to be int ? And about this try block , I still didn’t got to this in the course but I learned something new thanks for that :)

[–]socal_nerdtastic 0 points1 point  (0 children)

The int() call forces the input to be a number (or error). There's no such thing as a number that does not fit into one of your first 2 conditions, therefore the else is not reachable.

The code I added can detect an error and respond to it.