0

最小、最大、および特定の増分で特定の賭け金を要求しようとしています。次のコードを実行すると、プログラムは停止するのではなく、配列内のすべての要素をループします。

from pylab import *
import random
bank = 20000
betrange=range(100,20100,100)    
print "Hello Kathy, welcome to the Golden Brighton casino. We have reserved a high roller table for your bank of 20,000. How much would you like to bet per spin? The table has a 100 minimum bet with a maximum of 20,000."
print "The available legal bets are as follows:"
bet=raw_input("Place your bets please:") 
for i in range(len(betrange)):
    if betrange[i] == bet: 
       print bet,"Your bet has been accepted, can you make a million?"
       break
    else:
       print bet,"Please enter a legal bet. The table minimum is 100, with a maximum of 20000 in increments of 100."
4

1 に答える 1

2

あなたのコードは、ループよりも式としての方が良いようです:

if 100 <= bet <= 20000 and bet%100 == 0:
    print bet,"Your bet has been accepted"
else:
    print bet,"Please enter a valid bet"
于 2013-03-30T15:25:49.663 に答える