So I'm confused on how to make the invalid input appear for only number inputs, how to turn the inputs into a list, and how to increase the count for every input? I genuinely tried but I just can't figure it out :( .
This is the question:
Exercise #17c: Lists #3
You’re going to take the same idea from a previous exercise that asked the user for multiple numbers and until the user entered "done".
On the very top of your program, you need to
assign (=)
anempty list ([])
to a variable (line above the While True loop)The program is going to continuously ask for a list of names.
Once the user types in ‘done’, your program should then display how many names were entered and display the final list. An example is shown below of what yours should look like
EXAMPLE:
Enter a name: Mrs. Brown
Enter a name: Ms. Bliss
Enter a name: 3
That’s not a name! TRY AGAIN!
Enter a name: Mr. Kent
Enter a name: done
There are 3 names in the list [‘Mrs. Brown’, ‘Ms. Bliss’, ‘Mr. Kent’]
This is what is have so far:
namesList = []
while True:
name = input("Please enter a name, then press enter. When finished type done: \n")
if name == "done":
namesList = namesList[:-1]
print("There are " + str(len(namesList)) + " names in the list " + str(namesList))
break
else:
continue