Answer to Question #285782 in Python for adi

Question #285782

Write a python function to get three user information such as name,

address, phone number, email and store them in three separate file. 


1
Expert's answer
2022-01-09T10:44:05-0500
# 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()

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS