how would I be able to make something like this that actually works?
choices = input('Enter choices. ')
i = 0
while i < 10:
number_of_{}s.format(i) = choices.count(str([i]))
i += 1
how would I be able to make something like this that actually works?
choices = input('Enter choices. ')
i = 0
while i < 10:
number_of_{}s.format(i) = choices.count(str([i]))
i += 1
Use the tools the language gave you for this problem. Use lists.
i = 0
number_of = []
while i < 10:
number_of.append(choices.count(str([i])))
i += 1
Even better, use for
.
number_of = []
for i in range(10): number_of.append(choices.count(str([i])))
Or, best, a list comprehension.
number_of = [choices.count(str([i])) for i in range(10)]