Below is what I'm trying to do:
- Prompt user with the question "Do you want to add a student? "
- If user enters "Yes" they will be prompted with "Who do you want to add? "
- After adding the student's name, they will be prompted again with "Do you want to add a student? " until the user enters "No"
- If the user enters "No", I want to print all the students the user has entered.
With the little I know, I attempt to code it below:
students = []
initial_input = 'Yes'
second_input = ''
while initial_input == 'Yes':
initial_input = input('Do you want to add a student? ')
if initial_input == 'Yes':
second_input = input('Who do you want to add? ')
if initial_input == 'No':
students.append(second_input)
print(students)
When running it, it doesn't print out the names I entered below:
Do you want to add a user? Yes
Who do you want to add? John
Do you want to add a user? Yes
Who do you want to add? Tim
Do you want to add a user? No
[]
Process finished with exit code 0
Can someone kindly explain what I'm doing wrong?