Advertisement
DrAungWinHtut

signup.py

May 20th, 2023
949
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.88 KB | None | 0 0
  1. import os
  2.  
  3.  
  4. def SignUp():
  5.     username = input('please enter username: ')
  6.     filename = username + '.txt'
  7.     if os.path.exists(filename):
  8.         print('Username already exists, please choose another one: ')
  9.         SignUp()
  10.     else:
  11.         password = input('please enter password: ')
  12.         file = open(filename, 'w')
  13.         file.write(password)
  14.         file.close()
  15.  
  16.  
  17. def SignIn():
  18.     username = input('username: ')
  19.     password = input('password: ')
  20.     filename = username + '.txt'
  21.     try:
  22.         file = open(filename, 'r')
  23.         savepassword = file.read().rstrip()
  24.         file.close()
  25.         if savepassword == password:
  26.             print('Signing in....')
  27.             print('Success')
  28.         else:
  29.             print('Wrong password...')
  30.  
  31.     except FileNotFoundError:
  32.         print('No such username exists!')
  33.  
  34.  
  35. # Program Start Here
  36. SignUp()
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement