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...
JAVA Write a program that will compare two names. The program prompts the user to enter...
JAVA Write a program that will compare two names. The program prompts the user to enter two names for a comparison. If the names are same, the program states that. If the names are different, the program converts both names to UPPERCASE, and compares then again. If they are equal, the programs displays a message stating that names are equal if CASE is ignored. Otherwise, the program prints names with a message that names are not equal.  Check also if there...
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...
Write a C++ program, falling.cpp, that inputs a distance in meters from the user and computes...
Write a C++ program, falling.cpp, that inputs a distance in meters from the user and computes the amount of time for the object falling from that distance to hit the ground and the velocity of the object just before impact. Air resistance is discounted (assumed to fall in a vacuum). To compute the time, use the formula: t = Square Root (2d / g) where d is the distance in meters and g is the acceleration due to gravity on...
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...
IN JAVA WITH COMMENTS, The assignment: This program inputs the names of 5 students and the...
IN JAVA WITH COMMENTS, The assignment: This program inputs the names of 5 students and the (integer) grades they earned in 3 tests. It then outputs the average grade for each student. It also outputs the highest grade a student earned in each test, and the average of all grades in each test. Your output should look like this: Mary's average grade was 78.8% Harry's average grade was 67.7% etc... : In test 1 the highest grade was 93% and...
(write a program that get the numbers from user and search the file numbers.text for that...
(write a program that get the numbers from user and search the file numbers.text for that value. in C++) numbers.txt: 10 23 43 5 12 23 9 8 10 1 16 9 you must to have the exact output: Enter a number: 10 10 last appears in the file at position 9 Enter a number: 29 29 does not appear in the file Enter a number: 9 9 last appears in the file at position 12 Enter a number:
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT