I'm getting a IndexError: tuple index out of range
.
main.py
file:
import Bank
import Input
balance = Bank.ATM.get_balance()
amongus = str.format("Starting Balance: {:.2f}")
print(amongus)
amount = Input.Validator("Please enter deposit amount ($0.00 - $1000.00): ",0.00,1000.00)
deposit()
Bank.py
file:
class ATM:
def deposit(amount):
amongus = str.format("Depositing {:.2f}")
print(amongus)
balance = balance + amount
return balance
def withdraw(amount):
if balance >= amount:
amongus = str.format("Withdrawing {:.2f}")
print(amongus)
balance = balance - amount
else:
print("Insufficient funds")
return balance
def get_balance():
return balance
balance = 20.00
Input.py
file:
class Validator:
def get_integer(prompt, min, max):
while True:
try:
inputString = input(prompt)
inputInt = int(inputString)
if (inputInt >= min) and (inputInt <= max):
return inputInt
except:
continue
def get_float(prompt, min, max):
while True:
try:
inputString = input(prompt)
inputFloat = float(inputString)
if (inputFloat >= min) and (inputFloat <= max): # verify range
return inputFloat
except:
continue
The error I'm currently getting with my code is this:
Traceback (most recent call last):
File "main.py", line 4, in <module>
amongus = str.format("Starting Balance: {:.2f}")
IndexError: tuple index out of range
amongus
being just what I used as a temporary variable name until I come up with a better one.