Skip to content

Commit 99d041a

Browse files
committed
optimized open account func
1 parent faee96d commit 99d041a

1 file changed

Lines changed: 19 additions & 24 deletions

File tree

  • projects/Unstructured Supplemenrary Service Data

‎projects/Unstructured Supplemenrary Service Data/ussdtim.py‎

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def BVN_checker( ):
2222
global gen_bvn
2323
bvn = [str(i) for i in range (5)]
2424
gen_bvn= "".join(bvn)
25-
print (gen_bvn)
25+
2626

2727
def open_acct( ):
2828
global gen_bvn
@@ -34,12 +34,16 @@ def open_acct( ):
3434
s_name= input ("Enter your second name:")
3535
sex = input("Enter sex [M/F]:")
3636
BVN_checker( )
37-
temp_storage.extend(f_name)
38-
temp_storage.extend(s_name)
39-
temp_storage.extend(sex)
40-
temp_storage.extend(gen_bvn)
37+
temp_storage.append(f_name)
38+
temp_storage.append(s_name)
39+
temp_storage.append(sex)
40+
temp_storage.append(gen_bvn)
4141
details= " ".join(temp_storage)
42-
print(details)
42+
split_details = details.split(" ")
43+
#print(split_details)
44+
print(split_details[0]+" "+split_details[1])
45+
print(split_details[2])
46+
print("Your bvn is :"+split_details[3])
4347
print("1. Press # to go back to options menu\n2. Press * to exit")
4448
bck=input(":")
4549
if bck=='#':
@@ -138,26 +142,17 @@ def funds( ):
138142
# This is the function for options.
139143
def options_menu( ) :
140144
print("1. Open Account\n2. Upgrade/Migrate\n3. Balance\n4. Transfer\n5. Funds")
145+
select_options ={
146+
'1':open_acct,
147+
'2':upgrade_migrate,
148+
'3': balance,
149+
'4':transf,
150+
'5':funds}
141151
choice=input("Enter an option:")
142-
if choice == "1":
143-
time.sleep(10)
144-
open_acct( )
145-
elif choice == "2":
146-
time.sleep(10)
147-
upgrade_migrate( )
148-
elif choice =="3":
149-
time.sleep(10)
150-
balance( )
151-
elif choice =="4":
152-
time.sleep(10)
153-
transf( )
154-
elif choice =="5":
155-
time.sleep(10)
156-
funds( )
152+
if select_options.get(choice):
153+
select_options[choice]()
157154
else:
158-
time.sleep(5)
159-
print("Not an option.")
160-
sys.exit( )
155+
sys.exit()
161156

162157
# This is the function which prompts the user as to whether the user wishes to continue or stop transaction.
163158
def exit( ):

0 commit comments

Comments
 (0)