Question

In: Computer Science

Write a program called listful.py, in which the user inputs names, which get added to a...

Write a program called listful.py, in which the user inputs names, which get added to a list. Your program should:

· Include a comment in the first line with your name.

· Include comments describing each major section of code.

· Create a list.

· Ask the user to input a first name or hit enter to end the list.

· If the user adds a first name (i.e., anything other than a blank value):

o Add the name to the list.

o Tell the user that they’ve added [name] to the list (where [name] is the name that just got added).

o Ask the user (again) to input a first name — and keep asking until the user hits enter without adding another name (i.e., enters a blank value).

· Once the user enters a blank value:

o Tell the user how many names they added to the list.

o Using a for-loop, output all the names that are in the list, using a separate line for each name.

o Do not include the blank value in the list!

Solutions

Expert Solution

Code:

# Add your name here
# create a list
names = []

# we use while loop to keep accepting input names
while(1):
    name = input('Enter first name or hit enter to end the list: ')
    if(name == ''): # user has hit enter so end the list
        break
    names.append(name)
    print(name,'got added to list')

# tell user number of names they have added to list
print('Total names added =',len(names))

# use for loop to output names
for i in range(len(names)):
    print(names[i])

Code Screenshot:

Code output:

==============

Please add your author name in the code first line.

Please refer to the code and screenshot attached above.

Please upvote.


Related Solutions

Write a program called whilebun.py, in which the user is asked to guess the name of...
Write a program called whilebun.py, in which the user is asked to guess the name of your favorite DBVac vacuum cleaner model. Your program should: · Include a comment in the first line with your name. · Include comments describing each major section of code. · Set a variable called vacname to be equal to the name of your favorite DBVac vacuum cleaner model. · Ask the user to guess the name. Allow the user to make up to three...
Write a JAVA program that prompts the user for the number of names they’d like to...
Write a JAVA program that prompts the user for the number of names they’d like to enter. Create a new array of the size chosen by the user and prompt the user for each of the names. Output the list of names in reverse order.
C++ Vector Write a program that allows the user to enter the last names of the...
C++ Vector Write a program that allows the user to enter the last names of the candidates in a local election and the votes received by each candidate. The program should then output each candidate's name, votes received by that candidate, and the percentage of the total votes received by the candidate. Assume a user enters a candidate's name more than once and assume that two or more candidates receive the same number of votes. Your program should output the...
To do: Write a program names BarChartWhile that ask’s the user for today’s sales (to the...
To do: Write a program names BarChartWhile that ask’s the user for today’s sales (to the closest $100) at five stores. The program should display a bar chart comparing each store’s sales. Create each bar in the chart by displaying a row of asterisks. Each asterisk should represent $100 of sales. You must use a while loop to display the chart. Actually – you will need five while loops, one for each store. Those of you with some programming background,...
Develop a GUI to get unique names from the user.
in JAVADevelop a GUI to get unique names from the user. . In the first frame use a label ("Name") a textfield and 2 buttons (ext' and 'inished") . In the second frame there should be a list and a scrollpane as the components . Use the components on the first frame to get the name value from the user. . When the user enters a name make sure it is not empty and has no spaces and dicks the next' button, reset the...
In a file called LengthSum.java, write a program that: - Asks the user to enter a...
In a file called LengthSum.java, write a program that: - Asks the user to enter a string. - Asks the user to enter a second string. - Prints out the length of the first string, the length of the second string, and the sum of the two lengths, using EXACTLY the same format as shown below. For example: if the user enters strings "UT" and "Arlington", your program output should look EXACTLY like this: Please enter a string: UT Please...
Write a program to prompt the user to display the following menu: Guess-Number                        Concat-names     &
Write a program to prompt the user to display the following menu: Guess-Number                        Concat-names             Quit If the user selects Guess-number, your program needs to call a user-defined function called int guess-number ( ). Use random number generator to generate a number between 1 – 100. Prompt the user to guess the generated number and print the following messages. Print the guessed number in main (): Guess a number: 76 96: Too large 10 Too small 70 Close Do you...
Write a Java program to do the following: Ask the user to enter 10 first names...
Write a Java program to do the following: Ask the user to enter 10 first names (one word - no hyphen or apostrophe) using the keyboard. 1) Display the list of names one per line on the Console. 2) Display the names again, after eliminating duplicates using a HashSet (Your code MUST use HashSet).
Please code C# 10. Write a program that allows a user to input names and corresponding...
Please code C# 10. Write a program that allows a user to input names and corresponding heights (assumed to be in inches). The user can enter an indefinite number of names and heights. After each entry, prompt the user whether they want to continue. If the user enters true, ask for the next name and height. If the user enters false, display the name of the tallest individual and their height. Sample run: “Name?” James “Height?” 50 “Continue?” True “Name?”...
Write a C++ program using dynamic arrays that allows the user to enter the last names...
Write a C++ program using dynamic arrays that allows the user to enter the last names of the candidates in a local election and the number of votes received by each candidate. The program must ask the user for the number of candidates and then create the appropriate arrays to hold the data. The program should then output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT