Small improvement


#1



Replace this line with your code.


#2

yes?


#3

Quick observation, perhaps it was too in depth at this point, but I would have liked to have had to add some code to ensure the user guess was an integer. As it is now one enters a non integrt and the code breaks.


#4

This requires code which hasn't been taught yet:

while True:
    try:
        guess_row = int(raw_input("guess row: "))
        guess_coll = int(raw_input("guess coll: "))
    except ValueError:
        print "not vaild"
    else:
        break

#5

So mo simple solution such as an is num or is numeric.. bummer. Look forward to learning the tyy catch logic though.


#6

you can use isinstance (see this stackoverflow question), but that is it. Try/except is quit pythonic way of solving this problem

Try except is not caught in this course


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.