Sep-30-2018, 12:18 PM
(This post was last modified: Sep-30-2018, 12:18 PM by gruntfutuk.)
I'm not clear where you are going with this, especially the B55x2 line, so I've take the liberty of rewriting and extending what you've shared somewhat in the hope it will give you some ideas on how to achieve your intended objective.
In your original code, there is no means of entering/varying the amount, so I've chosen to make this a random amount, and I've also given the user an opening balance that the amount comes off of. If they win, they get their stake back, otherwise they lose their stake. (Incidentally, you'd varied the spelling of the amount variable.)
When the user runs out of money or either the host or the user gets a certain number of wins, the game ends. Your current code has an infinite loop in it.
I've shown how to use f-strings properly. (There could be calculations or functions calls inside of the {} if you wanted.)
The convention in Python followed by the majority of programmers is to use all lowercase in variable names, so I changed your variable names accordingly.
In your original code, there is no means of entering/varying the amount, so I've chosen to make this a random amount, and I've also given the user an opening balance that the amount comes off of. If they win, they get their stake back, otherwise they lose their stake. (Incidentally, you'd varied the spelling of the amount variable.)
When the user runs out of money or either the host or the user gets a certain number of wins, the game ends. Your current code has an infinite loop in it.
I've shown how to use f-strings properly. (There could be calculations or functions calls inside of the {} if you wanted.)
The convention in Python followed by the majority of programmers is to use all lowercase in variable names, so I changed your variable names accordingly.
from random import randint min = 1 max = 100 user = 'User' host = 'Host' amount = 10 user_balance = 1000 max_wins = 100 user_wins = 0 # introduced so the while loop does not run forever host_wins = 0 B55x2 = f'!55x2 {User} {Amount}' # no idea what this is for as it is never changed while user_wins < max_wins and host_wins < max_wins and user_balance > 0: amount = randint(1, user_balance) print(f'{user} bet on 55x2 vs {host} for a bet of {amount}') roll = randint(min, max) print (f'{host} rolled {roll} with percentile dice') if roll > 54: print(f'{user} has Won their bet!') user_wins += 1 user_balance += amount else: print(f'{host} has Lost their bet!') host_wins += 1 user_balance -= amount print(f'Host wins: {host_wins}, User wins: {user_wins} and balance: {user_balance}')
I am trying to help you, really, even if it doesn't always seem that way