I finished my program of craps! now I seem to be able to break it very easily...
How would I check if a value is a int or float before I convert it from a string... I tried using ValueError: but I think because the function is not part of a loop I cant... Sorry first time I needed to think of this!
My code works great if the user actually follows directions(HA!) but will break if I enter something like "THREE" instead of 3. Code:
def parse_message(msg):
if len(msg) >= 1:
msg = msg.split(' ')
options = {'!resetme': command_reset_player,
'!removebets': command_remove_bets}
if msg[0] == '!bet':
if msg[1] == 'place':
if int(msg[2]) in [4, 5, 6, 8, 9, 10] :
if float(msg[3]) > 1:
UpdateBets.PlaceBet(sender, int(msg[2]), float(msg[3]))
if msg[1] == 'pass':
if float(msg[2]) > 1:
UpdateBets.PassBet(sender, float(msg[2]))
if msg[1] == 'passodds':
if float(msg[2]) > 1:
UpdateBets.PassOdds(sender, float(msg[2]))
if msg[1] == 'hard':
if int(msg[2]) in [4, 6, 8, 10] :
if float(msg[3]) > 1:
UpdateBets.HardBet(sender, int(msg[2]), float(msg[3]))