I'm brand new to coding, taking an Intro to Python class, and I feel like I've been about 50% lost from the beginning. I'm trying to do the homework and I'm stuck. I want my program to do this:
Please enter a bird species or press Q to quit: Enters in Penguin
Penguin is added to the list.
Penguin
Please enter a bird species or press Q to quit: Enters in Eagle
Eagle is added to the list.
Penguin
Eagle
Please enter a bird species or press Q to quit: Enters in Sparrow
Sparrow is added to the list.
Penguin
Eagle
Sparrow
Please enter a bird species or press Q to quit: Enters QEnds program
Please enter a bird species or press Q to quit: Enters Q
Goodbye. Ends program
Like I said, I'm really new to this so if anyone could help me out that would be awesome. I just need it to repeat itself so it keeps asking and adding to the list. Thanks. I also can't figure out how to put my code in here properly so bear with me.
Here's my code:
bird_names = [ ]
answer = input('Please enter a bird species or type Q to quit: ')
if answer in bird_names:
print(answer, 'is already in the list.')
elif answer in 'Qq':
print('Goodbye.')
else:
bird_names.append(answer)
print(answer, 'added to the list.')
for i in range(len(bird_names)):
print(i, bird_names[i])