Write a python function to get three user information such as name,
address, phone number, email and store them in three separate file.
# Python 3.9.5
def get_data(user_id):
name = input(f'Enter name user {user_id}: ')
address = input(f'Enter address user {user_id}: ')
phone_number = input(f'Enter phone number user {user_id}: ')
email = input(f'Enter email user {user_id}: ')
return name, address, phone_number, email
def execution(user_c):
i = 1
while i <= user_c:
name, address, phone_number, email = get_data(i)
f = open(f"{name}.txt", "w+")
f.write(f'{name}\n{address}\n{phone_number}\n{email}')
f.close()
i += 1
def user_count():
user_count = int(input('Enter number of users: '))
return user_count
def main():
user_c = user_count()
execution(user_c)
if __name__ == '__main__':
main()
Comments
Leave a comment