I am working on a scratch lottery command on my python game.
My Scratch lottery function is below.
def lottery(player_money): print('scratch lottery :') print('price: 500') print('wins :') print(' all 6 same : $100000') print(' all 5 same : $50000') print(' all 4 same : $10000') print(' all 3 same : $1000') print(' all 2 same : $300') print('do you want to buy it?? yes/no') buy = input('> ') if buy == 'no': print('please come back later!!') return player_money elif buy == 'yes': print('_____________') lottery_results = ['x', 'o', 'p', 'k', 'm', 'e', 'a', 'w'] a = random.choice(lottery_results) b = random.choice(lottery_results) c = random.choice(lottery_results) d = random.choice(lottery_results) e = random.choice(lottery_results) f = random.choice(lottery_results) print('| ' + a + ' | ' + b + ' | ' + c + ' |') print('|_' + d + '_|_' + e + '_|_' + f + '_|') if... I Have no idea what to put after
if... I don't want to make if for all possible solutions since that would be like 2 million ifs.
I want to make it like below
If 2 of the str in a or b or c or d or e or f is the same: print('Since 2 matched, you won $300!') player_money += 300 return player_money I don't know how to code(ify) the phrase that goes after if and the phrase that goes after if that I put in wouldn't work and there would be a error
Any suggestions on how I could make this work?
https://stackoverflow.com/questions/67051310/scratch-lottery-function April 12, 2021 at 08:15AM
没有评论:
发表评论