I am new to Python, and I am currently learning about lists. This is the question that I am trying to solve:
Your favourite band is in town, and tickets are selling fast! Alas, you were too late to snag one, so you put your name in the waitlist, in case any extra tickets are released.
Write a program to manage the waitlist for the concert.
Your program should read in a list of the names in the waitlist, and the number of extra tickets released.
Then, it should announce the names of people who score the extra tickets.
Here's an example of how your program should work:
People in line: Dave, Lin, Toni, Markhela, Ravi Number of extra tickets: 3 Tickets released for: Dave, Lin, ToniNote: The names are separated by a comma and a space (', ').
If there are no more tickets released, your program should work like this:
People in line: Mali, Micha, Mary, Monica Number of extra tickets: 0 Fully Booked!This band is so popular that there will always be at least as many people as extra tickets. You won't have to worry about index errors.
I have tried the following, but it always prints the entire list, not just a subset.
ppl = []
sep = ', '
ppl_in_line = input('People in line: ')
ppl.append(ppl_in_line)
x = int(input('Number of extra tickets: '))
if x == 0:
print('Fully Booked!')
else:
y = ppl[:x]
print('Tickets released for: ' + (sep.join(y)))