I'm a very beginner in computer language (2 days) and am writing a basic slot machine code in python.
import random
import time
balance = 1000
print("Welcome to the Slot World")
player_name = input("What's your name?")
while balance > 0:
print(player_name, ", you have $",balance, " to bet.")
bet = int(input("How much do you want to bet?"))
x = random.randint(1, 5)
y = random.randint(1, 5)
z = random.randint(1, 5)
numbers = [x, y, z]
if bet != int:
print("Please enter correct amount")
continue
elif bet > balance:
print("You do not have sufficient amount")
continue
elif bet <= 0:
print("Please enter correct amount")
continue
else:
print("You have bet $", bet)
time.sleep(0.5)
print(numbers)
balance = balance - bet
if x == y and y == z:
if x == 1:
print("Winner 20x!")
bet = bet * 20
balance = balance + bet
elif x == 2:
print("Winner 30x!")
bet = bet * 30
balance = balance + bet
elif x == 3:
print("Winner 40x!")
bet = bet * 40
balance = balance + bet
elif x == 4:
print("Winner 50x!")
bet = bet * 50
balance = balance + bet
elif x == 5:
print("Winner 100x!")
bet = bet * 100
balance = balance + bet
elif x == y and not y == z:
if x == 1:
print("Winner 2x")
bet = bet * 2
balance = balance + bet
elif x == 2:
print("Winner 3x")
bet = bet * 3
balance = balance + bet
elif x == 3:
print("Winner 4x")
bet = bet * 4
balance = balance + bet
elif x == 4:
print("Winner 5x")
bet = bet * 5
balance = balance + bet
elif x == 5:
print("Winner 10x")
bet = bet * 10
balance = balance + bet
elif not x == y and y == z:
if y == 1:
print("Winner 2x")
bet = bet * 2
balance = balance + bet
elif y == 2:
print("Winner 3x")
bet = bet * 3
balance = balance + bet
elif y == 3:
print("Winner 4x")
bet = bet * 4
balance = balance + bet
elif y == 4:
print("Winner 5x")
bet = bet * 5
balance = balance + bet
elif y == 5:
print("Winner 10x")
bet = bet * 10
balance = balance + bet
elif not x == y and x == z:
if x == 1:
print("Winner 2x")
bet = bet * 2
balance = balance + bet
elif x == 2:
print("Winner 3x")
bet = bet * 3
balance = balance + bet
elif x == 3:
print("Winner 4x")
bet = bet * 4
balance = balance + bet
elif x == 4:
print("Winner 5x")
bet = bet * 5
balance = balance + bet
elif x == 5:
print("Winner 10x")
bet = bet * 10
balance = balance + bet
else:
print("Bad Luck! You Lost!")
print("You lost all your money\nThe End")
If I input a character for bet
bet = int(input("How much do you want to bet?"))
it gives me
ValueError: invalid literal for int() with base 10: 'a'