Python Help

ساخت وبلاگ
Hi All im working on a project and im about to just give up i cant seem to get this to work.

Is there anyone that can help Im very new to python.


Code:

import random
import sys

def inputNumber(message):
while True:
try:
userinput = int(input(message))
except ValueError:
print("Please enter a valid number Try again.")
continue
else:
return userinput



def continue_question():
continue_question = inputNumber(" Would you like to continue 1 for Yes 2 for No")
if continue_question == 1:
welcome()
else:
print("Goodbye")
sys.exit()


pin,balance,name = [],[],[]
for line in open('bank.txt', 'r').readlines():
columns = line.split()
pin.append(columns[0])
balance.append(columns[1])
name.append(columns[2] + " " + columns[3])




def welcome():

print("Welcome to Banking Management System ")
print("+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+")
print("Please choose from List below")
print()
print()
options =inputNumber("1. Open an accountn2. Close an accountn3. Withdraw moneyn4. Deposit moneyn5. Generate a report for managementn6. Quit")

if options == 1:
open_account()

elif options == 2:
close_account(pin,balance)
elif options == 3:
withdraw_money(pin,balance)
elif options == 4:
deposit_money(pin,balance)
elif options == 5:
generate_report_management()
elif options == 6:
sys.exit()





def open_account():
acc_number = random.randint(100000, 999999)
if acc_number in pin:
open_account()

acc_name = input("Please enter your Name")
acc_balance = 0
print("You Pin number is ", acc_number)
print("Your balance is ",acc_balance)
print(pin,balance,name)
pin.append(acc_number) # add account number to list
name.append(acc_name) # add account holder name to list
balance.append(acc_balance)#add balance to account
continue_question()






def withdraw_money(pin,balance):
withdraw_from_pin = inputNumber("Please enter Pin for Account you want to withdraw from")
amount_withdraw =inputNumber("Please enter the amount you would like to withdraw ")
pin_call = pin.index(withdraw_from_pin)
current_balance = balance[pin_call]
if amount_withdraw > current_balance:
print("You have do not have funds for this transaction")
else:
new_balance = balance - amount_withdraw
print("your Balance is ", new_balance)

continue_question()





def deposit_money(pin,balance):
deposit_to_pin = inputNumber("Please enter Pin for Account you want to deposit to")
amount_deposit = inputNumber("Please enter the amount you would like to Deposit")
pin_call = pin.index(deposit_to_pin)
current_balance = balance[pin_call]
new_balance = current_balance + amount_deposit
print("Your new balance is ",new_balance)
continue_question()




def close_account(pin,balance):
remove_pin = input("Please enter Pin for Account you want to close ")
pin_call = pin.index(remove_pin)
print("Your account is now closed")
remove_account = pin_call.index.remove[remove_pin]

def generate_report_management():
return

def main():
welcome()



main()

CodingForums...
ما را در سایت CodingForums دنبال می کنید

برچسب : نویسنده : codingforums بازدید : 150 تاريخ : شنبه 1 ارديبهشت 1397 ساعت: 18:29