forked from Masood-Zain/WebPaisa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.py
45 lines (36 loc) · 1.04 KB
/
index.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import database
def main():
db = database.Database()
print(f"Loaded {len(db.data['users'])} users")
username = input("Username: ")
user = db.get_user(username)
if user is None:
print("User not found")
return
password = input("Password: ")
if not db.login(username, password):
print("Incorrect password")
return
print("Logged in successfully")
print(f"Balance: {user['balance']}")
print()
while True:
print("1. Deposit")
print("2. Withdraw")
print("3. Exit")
choice = input("> ")
if choice == "1":
amount = int(input("Amount: "))
user["balance"] += amount
elif choice == "2":
amount = int(input("Amount: "))
if amount > user["balance"]:
print("Insufficient balance")
continue
user["balance"] -= amount
elif choice == "3":
break
else:
print("Invalid choice")
if __name__ == '__main__':
main()