This is a Python question. How do I get the following code to create a numerical list of guest names: guest_name = ""counter = 0output = ""while True:guest_name = input("Guest's Name (or press Enter to quit): ")if guest_name.lower() != "":continueelif guest_name.lower() == "" :breaki = 0print("My Wedding Attendees are: ")output = output + str(counter + 1) + "." + guest_name + "\n"print(output)

Question
Asked Feb 26, 2019
12 views

This is a Python question. How do I get the following code to create a numerical list of guest names: 

guest_name = ""
counter = 0
output = ""
while True:
guest_name = input("Guest's Name (or press Enter to quit): ")
if guest_name.lower() != "":
continue

elif guest_name.lower() == "" :
break

i = 0
print("My Wedding Attendees are: ")

output = output + str(counter + 1) + "." + guest_name + "\n"

print(output)

check_circle

Expert Answer

Step 1

We need to convert the guest_name variable as a Python list of 50 elements and initialize each elemeto to None like :-

guest_name = [None]*50

 

Step 2

We need to accept each guest name from the user and store it in the list like :-

guest_name[counter] = input("Guest's Name (or press Enter to quit): ")

Step 3

We need to increment the counter by 1 each time inside the if block like:-...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Programing Language

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: How do I convert a number to octal without using modulus, multiplication, and division. Also, I can'...

A: To convert an integer number to octal without using multiplication, division and modulus or any inbu...

question_answer

Q: health informatics

A:  I think the student wants to know what health informatics is, so we will be providing a brief intro...

question_answer

Q: Construct an unambiguous grammar equivalent to the grammar in  S→AB|aaaB, A→a|Aa, B→b.

A: Solution: Construct an unambiguous grammar to grammar.Given that,S -> AB|aaaBA -> a|AaB -> ...

question_answer

Q: how can I write a statement in C++ that would print last name, followed by a comma, followed by firs...

A: Given below is the C++ program to print a statement with last name, followed by comma, followed by f...

question_answer

Q: Consider the following procedure: procedure mystery (x, y, z); integer x, y, z;beginz = 2; y= z+x;en...

A: Pass by reference copies the location of argument to the parameter. Hence, the final value of n, A[1...

question_answer

Q: Create a list of 3 technologies that have gone from analog to digital. What was the reasoning for e...

A: Back in 1970s and earlier main technology in use was analog technology. Analog technology used vario...

question_answer

Q: I need help with creating a main.css, I already have the HTML.the details are in the pic and I will ...

A: You can use following code in your main.css file to format your HTML document.Note: Make use of <...

question_answer

Q: 1. What is the output of the following code? public class Loopy {public static void main(String[] ar...

A: 1. Algorithm for the given code is as follows:The variable ""x is initialized as "1" within the "mai...

question_answer

Q: Consider the following procedure: procedure mystery (x, y, z); integer x, y, z;beginz =2; y = z + x;...

A: Call by reference The arguments passed to a function will copy the address of an argument into the f...