1
사용자가 새로운 베팅을 할 때마다 새로운 난수를 생성하려면 어떻게해야합니까? 현재는 매번 실행할 때마다 숫자 2가 생성됩니다. 또한 홀수 생성 번호는 빨간색과 검정색이어야합니다.코드는 모든 룰렛 스핀에 대해 새로운 번호를 생성하지 않습니다.
import random
def roulette_wheel():
# opening interface
print("Welcome to the Roulette Wheel \nYou currently have $100 \nEnter a number 0-36 to bet on a number, -1 to bet on Black, -2 to bet on Red, or -3 to walk away. ")
#amount of money that the user begins with
user_flow = 100
while user_flow >= 1:
user_bet = input("What will you do:")
number = random.randint(1,36)
for number in (1, 35, 2):
color = ('red')
for number in (2, 36,2):
color = ('black')
# betting on black
if user_bet == '-1':
print("You are betting on black")
money = int(input("What is your bet:$"))
print('The result of the spin was', color, number)
if color == 'black':
user_flow = 2 * money + user_flow
print('Congrats! You now have $%d' %(user_flow))
else:
user_flow = user_flow - money
print('Sorry! You now have $%d' %(user_flow))
`