TransWikia.com

can anyone explain me the background process of this code

Stack Overflow Asked by funtastic world on November 18, 2021

input_string = input("Enter family members separated by space ")
family_list = input_string.split(" ")
print("n")
print("Here is the list in alphabetical order:")

for name in sorted (family_list):
    print(name)

One Answer

1. input_string = input("Enter family members separated by space ")

This line request for a user to enter names, separate them by commas. The names are stored as a single string in "input_string"

2. family_list = input_string.split(" ")

This line will convert the names in the string into arrays by separating them by the use a comma.

3. print("n")

This line prints an empty line.

4. print("Here is the list in alphabetical order:") This line will just print the text in quotes inside the print function in a new line

5. for name in sorted (family_list): print(name)

This line will take the array names created at line 2, sort them alphabetically then print then line by line following that order.

Answered by Albert Alberto on November 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP