Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- '''
- Task 3.2
- By Mark Wu
- @markwu.me
- '''
- # import os
- # -----------------Welcome screen-----------------
- print("-----------------Task 3.2-----------------")
- print('''
- -----Task 3 Overview-----
- [1] (Task 3.1) Create new records
- [2] (-----SELECTED-----) See current records
- [3] (Task 3.3) Find member ID
- [4] (Task 3.4) Add new users
- ''')
- # -----------------Task 3.2-----------------
- # The following are the functions used in the program
- # Initialization
- member_list = [] # List
- # Check if file exists:
- # file_found = os.path.isfile('record.txt') # Boolean
- file_found = True # Can't do this validation because I can't import
- if file_found:
- try:
- with open('record.txt') as myfile:
- content = myfile.readlines()
- for each in content:
- each_member = each.split(',')
- each_member[1] = each_member[1].strip() # remove line breakers
- each_member[0] = each_member[0].ljust(25) # fill up to 25 characters for column neatness
- member_list.append(each_member)
- except:
- print("Invalid record format.")
- else:
- print('''
- --------Current Record--------
- Name Member ID
- ''')
- for each in member_list:
- print(each[0] + each[1])
- else:
- print("File not exist!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement