My code works for user output alignment to the right side by maximum length of 4 different user input. I have 2 question.
- Is there a simplier way for append method in my code ?
- Is there a simplier way for right alignment by maximum legth of 4 different user input.
Thank You for Your Time...
"""
Main purpose of this code is alignment of the user output to the right
"""
# Take Input from User
name = input("Name: ")
surname = input("Surname: ")
age = input("Age: ")
occupation = input("Occupation: ")
person_dict = {"Name": name, "Surname": surname, "Age": age, "Occupation": occupation}
# Calculate Maximum Character Length
len_list1 = []
len_name = len(name)
len_list1.append(len_name)
len_surname = len(surname)
len_list1.append(len_surname)
len_age = len(age)
len_list1.append(len_age)
len_occupation = len(occupation)
len_list1.append(len_occupation)
a = max(len_list1)
# Output
print(f'Name: {person_dict["Name"]:>{a}}\n'
f'Surname: {person_dict["Surname"]:>{a}}\n'
f'Age: {person_dict["Age"]:>{a}}\n'
f'Occupation: {person_dict["Occupation"]:>{a}}'
)