我有一个制定投注计划的学校项目。它会询问帐户余额并检查用户是否可以玩更多游戏,或者告诉他们在破产时停止。我不知道如何添加一个 while 循环来检查他们是否有足够的钱再玩一次,并询问他们是否想再玩一次。
代码如下:
import random
for x in range (1):
x=random.randint(1,31)
point=int(0)
savings = int(input("Enter your total amount of money you have in your bank account"))
betmoney = int(input("Enter the money you are betting"))
num = int(input("Enter a number between 1 and 30"))
bef = (savings - betmoney)
if num == x:
print ("you have guessed the mystery number well done. Your earnings just got multiplied by 6")
point = point + 6
import random
for x in range (1):
x=random.randint(1,31)
if num % 2 == 0:
print("since your number is even, you get double your money back")
point = point + 2
else:
point = point + 0
if num % 10 == 0:
print("since your number is a multiple of 10 you get 3x your money back")
point = point + 3
else:
point = point + 0
for i in range(2,num):
if (num % i) == 0:
point = point +0
break
else:
print(num,"is a prime number so you will get 5x your money back")
point = point + 5
if num < 5:
print("since your number is lower than 5 you get double your money back")
point = point + 2
else:
point = point + 0
else:
print("unfortunatley you have nor guessed the right mystery number. better luck next time.")
win = (point * betmoney)
aft = (bef + win)
print ("Your bank account after playing is now" , aft)
print ("You have won" , win)
print ("btw the mystery number was" , x)