It is unclear what should happen with Justin Bieber (should he be excluded from printing out) and should enumeration be continous or not (in example there are 1, 2, 4, 5)
Following approach assumes that Justin Bieber must be included and only message should be displayed.
Start with defining what should happen in spoken language:
In 3.8 <= Python it could look like:
Following approach assumes that Justin Bieber must be included and only message should be displayed.
Start with defining what should happen in spoken language:
Output:repeat 7 times:
if something is anwered:
if answer is justin bieber then express disdain
store answer somewhere
else (no answer):
print message that there is less than 7
break
You can get to else branch only if there are less than 7 answers (if there are 7 answers for-loop will stop itself with no possibility to end in else branch).In 3.8 <= Python it could look like:
artists = list() for i in range(7): # repeat seven times if (artist := input('Enter Musical Artist: ')): # if there is an answer (truthy, i.e. not empty) if artist.lower() == 'justin bieber': # if the answer is justin bieber print('No way!') artists.append(artist) # append artist to list (even Justin Bieber) else: # nothing entered print("That's less than seven but it's ok.") break print(*(f'{num}. {artist}' for num, artist in enumerate(artists, start=1)), sep='\n')
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.