class Account():
accounts = []
def welcome(self):
print('Welcome to the Virtual Bank of Uday')
print(' ')
print('[1] Create an account')
print('[2] Sign in')
print('[3] View accounts')
print('[4] Bypass to Bank Menu')
ans = int(input('Choose an option [1-4]')
if ans == 1: # THIS IS WHERE THE ERROR IS (it will not let me assign 1)
self.createAccount()
elif ans == 2:
self.signIn()
elif ans == 3:
self.viewAccount()
elif ans == 4:
bank.menu()
def createAccount(self):
print(' ')
name = input('Please type your first name')
self.accounts.append(name)
input('Please press ENTER to visit the virtual bank ATM')
bank.menu()
def signIn(self):
print(' ')
signIn = input('Username: ')
if signIn in self.accounts:
print(' ')
print('The account is valid')
print('Press ENTER to visit the virtual bank ATM')
bank.menu()
else:
print(' ')
print('The account is invalid')
print('Please press ENTER to create an account')
self.createAccount()
def viewAccount():
print(' ')
print('User accounts')
for i in range(0, len(self.accounts)):
print(i)
print('Press ENTER to go back')
self.welcome()
start = Account()
start.welcome()
The compiler will not let me assign to an integer for some odd reason. My other class of code works perfectly and I used the same style of assignment. Coming here for last chance aid because I really want this code to work for my family and friends (just for fun). After I comment out the line with the error just to see if everything else will run, the syntax error moves on down each line claiming everything (one by one) is an error. Doesn't make sense when other similar class works fine. Anything i'm blatantly missing here? Thanks for your help. Coded on Spyder IDE in Python 3
Aucun commentaire:
Enregistrer un commentaire