[Tutor] Loop Exception Handles

Vincent Balmori vincentbalmori at yahoo.com
Sat Mar 16 05:08:48 CET 2013


I am trying to loop a simple exception. I tried to put a while loop, but I keep getting syntax issues. I also tried to alternatively use something on the lines of "while number != int" also with no avail.   

def main():
    print("\t\tWelcome to Blackjack!\n")
    
    names = []
    try:
        number = games.ask_number("How many players? (1 - 7): ", low = 1, high = 8)
    except (ValueError, TypeError):
        print("That is not a number!")
        number = games.ask_number("How many players? (1 - 7): ", low = 1, high = 8)
        continue
    for i in range(number):
        name = input("Enter player name: ")
        names.append(name)
    print()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20130315/a3422323/attachment.html>


More information about the Tutor mailing list