I expected that the code would ask me for input as many times as I want and then print out the number of times the input has been entered along with the name, capitalized. However, it only prints out the last input with 1 in front of the input
Can you tell where am I wrong
n=1
while True:
try:
lst = [
input('Enter name here: ')
]
except (KeyboardInterrupt):
for n in lst:
print(lst.count(n), n.upper())
New contributor